Transport layer
Transport layer
• The Transport layer is a 4th layer from the top.
• The main role of the transport layer is to provide the
communication services directly to the application processes
running on different hosts.
• A Computer Network provides more than one protocol to the
network applications. For example, TCP and UDP are two
transport layer protocols that provide a different set of services to
the network layer.
• Each of the applications in the application layer has the ability to
send a message by using TCP or UDP. The application
communicates by using either of these two protocols. Both TCP
and UDP will then communicate with the internet protocol in the
internet layer. The applications can read and write to the transport
layer. Therefore, we can say that communication is a two-way
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.
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.
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 the reliable
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.
THE Elements of Transport Protocols
• Addressing
• Connection Establishment
• Reliable Delivery
• Multiplexing
• Error Control Flow Control
• Addressing
The transport layer interacts with the functions of the session layer. Many
protocols combine session, presentation, and application layer protocols
into a single layer known as the application layer. In these cases, delivery
to the session layer means the delivery to the application layer. Data
generated by an application on one machine must be transmitted to the
correct application on another machine. In this case, addressing is
provided by the transport layer.
The transport layer provides the user address which is specified as a
station or port. The port variable represents a particular TS user of a
specified station known as a Transport Service access point (TSAP).
• Connection Establishment
The transport layer creates and releases the connection across the network.
This includes a naming mechanism so that a process on one machine can
indicate with whom it wishes to communicate. The transport layer enables
us to establish and delete connections across the network to multiplex
several message streams onto one communication channel.
• Reliable delivery:
The transport layer provides reliability services by retransmitting the lost and damaged
packets.
• The reliable delivery has four aspects:
• Error control
• Sequence control
• Loss control
• Duplication control
• Error control and 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.
Error detection and error recovery are an integral part of reliable service, and therefore they
are necessary to perform error control mechanisms on an end-to-end basis. To control
errors from lost or duplicate segments, the transport layer enables unique segment
sequence numbers to different packets of the message
The transport layer checks for errors in the messages coming from the application layer by
using error detection codes, and computing checksums, it checks whether the received data
• Multiplexing
Multiplexing(many to one) is when data is acquired from
several processes from the sender and merged into one
packet along with headers and sent as a single packet.
Multiplexing allows the simultaneous use of different
processes over a network that is running on a host. The
processes are differentiated by their port numbers.
Similarly, DE multiplexing(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.
Port Numbers
INTERNET TRANSFER PROTOCOL :UDP
• User Datagram Protocol (UDP) is a Transport Layer
protocol.
• It is an unreliable and connectionless protocol. So,
there is no need to establish a connection prior to data
transfer. The UDP helps to establish low-latency and
loss-tolerating connections establish over the network.
The UDP enables process to process communication.
• User Datagram Protocol (UDP) is used for time-critical
data transmissions such as DNS lookups, online
gaming, and video streaming.
• How Does UDP Work?
• User datagram protocol is a standardized communication
protocol that transfers data between computers in a
network.
• It does not feature a mandatory ‘handshake’ between the
sender and the receiver before the commencement of data
transfer.
• It is primarily used to establish low-latency and loss-
tolerating connections between applications on the
internet.
UDP
• UDP is used when acknowledgement of data does not hold
any significance.
• UDP is good protocol for data flowing in one direction.
• UDP is simple and suitable for query based
communications.
• UDP is not connection oriented.
• UDP does not provide congestion control mechanism.
• The UDP header contains four fields:
• Source port number: It is 16-bit information that identifies
which port is going t send the packet.
• Destination port number: It identifies which port is going to
accept the information. It is 16-bit information which is used to
identify application-level service on the destination machine.
• Length: It is 16-bit field that specifies the entire length of the
UDP packet that includes the header also. The minimum value
would be 8-byte as the size of the header is 8 bytes.
• Checksum: It is a 16-bits field, and it is an optional field. This
checksum field checks whether the information is accurate or not
as there is the possibility that the information can be corrupted
while transmission. It is an optional field, which means that it
depends upon the application, whether it wants to write the
checksum or not.
Transmission Control Protocol (TCP)
• Transmission Control Protocol (TCP) is a
communications standard that enables application
programs and computing devices to exchange
messages over a network. It is designed to
send packets across the internet and ensure the
successful delivery of data and messages over
networks.
• Transmission Control Protocol (TCP) is a communications
standard that enables application programs and computing
devices to exchange messages over a network.
• Source port: It defines the port of the application, which is sending
the data. So, this field contains the source port address, which is 16 bits.
• Destination port: It defines the port of the application on the
receiving side. So, this field contains the destination port address, which
is 16 bits.
• Sequence number: This field contains the sequence number of data
bytes in a particular session.
• Acknowledgment number: When the ACK flag is set, then this
contains the next sequence number of the data byte and works as an
acknowledgment for the previous data receiver.
• Header Length (HLEN): It specifies the size of the TCP header in
32-bit words. The minimum size of the header is 5 words, and the
maximum size of the header is 15 words. Therefore, the maximum size
of the TCP header is 60 bytes, and the minimum size of the TCP header
is 20 bytes.
• Reserved: It is a six-bit field which is reserved for future use.
• Control bits: Each bit of a control field functions individually and
independently. A control bit defines the use of a segment or serves as a
• There are total six types of flags in control field:
• URG: The URG field indicates that the data in a segment is urgent.
• ACK: When ACK field is set, then it validates the acknowledgement
number.
• PSH: The PSH field is used to inform the sender that higher throughput is
needed so if possible, data must be pushed with higher throughput.
• RST: The reset bit is used to reset the TCP connection when there is any
confusion occurs in the sequence numbers.
• SYN: The SYN field is used to synchronize the sequence numbers in three
types of segments: connection request, connection confirmation ( with the
ACK bit set ), and confirmation acknowledgement.
• FIN: The FIN field is used to inform the receiving TCP module that the
sender has finished sending data. It is used in connection termination in
three types of segments: termination request, termination confirmation, and
acknowledgement of termination confirmation.
• Window Size: The window is a 16-bit field that defines the size of the window.
• Checksum: The checksum is a 16-bit field used in error detection.
• Urgent pointer: If URG flag is set to 1, then this 16-bit field is an offset from
the sequence number indicating that it is a last urgent data byte.
• Options and padding: It defines the optional fields that convey the additional
information to the receiver.
• TCP Connection Establishment:
• To establish a connection, one side, say the server, passively waits for
an incoming connection by executing the LISTEN and ACCEPT
primitives in that order, either specifying a specific source or nobody
in particular.
• The other side, say, the client, executes a CONNECT primitive,
specifying the IP address and port to which it wants to connect, the
maximum TCP segment size it is willing to accept, and optionally
some user data (e.g., a password).
• The CONNECT primitive sends a TCP segment with the SYN bit on
and ACK bit off and waits for a response.
• When this segment arrives at the destination, the TCP entity there
checks to see if there is a process that has done a LISTEN on the port
given in the Destination port field. If not, it sends a reply with the
RST bit on to reject the connection.
• If some process is listening to the port, that process is given the
incoming TCP segment. It can either accept or reject the connection.
If it accepts, an acknowledgement segment is sent back. The
sequence of TCP segments sent in the normal case is shown in Fig
• TCP Connection Termination:
• TCP provides for a graceful close that involves
independent termination of each direction of the
connection. A termination is initiated when an
application tells TCP that it has no more data to
send.
• The TCP entity completes transmission of its data
and upon receiving acknowledgement from the
receiver, issues a segment with the FIN bit set.
• Upon receiving a FIN segment, A TCP entity
informs its application that the other entity has
terminated its transmission of data.
• TCP CONNECTION AND ESTABLISHMENT
• TCP uses a three-way handshake method to establish a connection
between two devices. The process involves the following steps:
• The first device sends a SYN (synchronize) packet to the second
device, indicating its intent to establish a connection.
• The second device receives the SYN packet and sends a SYN-ACK
(synchronize-acknowledge) packet back to the first device, indicating
its agreement to establish a connection.
• The first device receives the SYN-ACK packet and sends an ACK
(acknowledge) packet back to the second device, indicating that it has
received the second device’s response and is ready to communicate.
• Once the three-way handshake is complete, the devices are connected,
and data can be exchanged.
• To terminate a TCP connection, either device can send a FIN (finish)
packet to the other device, indicating that it no longer wants to
communicate. The other device responds with an ACK packet, and then
sends its own FIN packet to confirm the termination. The first device
responds with another ACK packet, and the connection is closed.
• TCP SLIDING WINDOW
• A TCP window is the amount of unacknowledged data a
sender can send on a particular connection before it gets an
acknowledgment back from the receiver, that it has received
some of the data.
• The sending device can send all packets within the
TCP window size (as specified in the TCP header) without
receiving an ACK, and should start a timeout timer for each of
them.
• The receiving device should acknowledge each packet it
received, indicating the sequence number of the last well-
received packet. After receiving the ACK from the receiving
device, the sending device slides the window to right side.
• If any TCP Segment lost while its journey to the
destination, the receiving device cannot acknowledge the
sender. Consider while transmission, all other Segments
reached the destination except Segment 3. The receiving
device can acknowledge up to Segment 2. At the sending
device, a timeout will occur and it will re-transmit the
lost Segment 3. Now the receiving device has received
all the Segments, since only Segment 3 was lost. Now
the receiving device will send the ACK for Segment 5,
because it has received all the Segments to Segment 5.
• Acknowledgement (ACK) for Segment 5 ensures the
sender the receiver has succesfully received all the
Segments up to 5.
TCP Sliding Window
• The available window advertised by the receiver is 6. This
means that receiver can accept 6 bytes as of now.
• The window at sender side covers bytes ranging from 13 to 18
(i.e. 6 bytes in total).
• Out of this range, 13-15 are the bytes which have been sent but
no acknowledgement is yet received for them.
• Bytes 16-18 are the bytes that sender can send as soon as
possible.
• If sender starts receiving acknowledgement for bytes 13 to 15,
the left end of the window starts closing in.
• The right end starts opening up as more and more window size
is advertised by the receiver.
• This window slides towards right depending upon how fast
receiver consumes data and sends acknowledgement and hence
TCP TIME MANAGEMENT
• Time Out Timer:TCP uses a time out timer for
retransmission of lost segments.
• Time Wait Timer:TCP uses a time wait timer during
connection termination.
• Keep Alive Timer:TCP uses a keep alive timer to
prevent long idle TCP connections.
• Persistent Timer:TCP uses a persistent timer to deal
with a zero-widow-size deadlock situation.
EXAMPLE
• A good example of how this works in practice
is when an email is sent using SMTP from an
email server
TCP UDP
It stands for Transmission Control It stands for User Datagram Protocol.
Protocol.
It is a Connection-Oriented protocol It is a Connectionless protocol
Slow Speed High Speed
TCP is a reliable protocol as it provides UDP is an unreliable protocol as it
assurance for the delivery of data does not take the guarantee for the
packets. delivery of packets.
The size of TCP Header is 20 bytes. The size of the UDP header is 8 bytes.
TCP performs error checking by using It does not perform any error
a checksum checking,
Used in military services, web Game streaming, video and music
browsing, and e-mail. streaming, etc.
It waits for the acknowledgement of It neither takes the
data and has the ability to resend the acknowledgement, nor it retransmits
lost packets. the damaged frame.
TCP UDP
TCP establishes a virtual circuit before UDP transmits the data directly to the
transmitting the data. destination computer without verifying
whether the receiver is ready to receive or
not.
Able to Sequence Unable to Sequence
Does not support Broadcasting Does support Broadcasting
Used by HTTPS, HTTP Video conferencing,
Application Layer
• The application layer in the OSI model is the closest
layer to the end user which means that the application
layer and end user can interact directly with the
software application.
• The application layer in the OSI model generally acts
only like the interface which is responsible for
communicating with host-based and user-facing
applications.
FUNCTION OF APPLICATION LAYER
• Application Layer provides a facility by which users can forward
several emails and it also provides a storage facility.
• This layer allows users to access, retrieve and manage files in a
remote computer.
• It allows users to log on as a remote host.
• This layer provides access to global information about various
services.
• This layer provides services which include: e-mail, transferring
files, distributing results to the user, directory services, network
resources and so on.
• It provides protocols that allow software to send and receive
information and present meaningful data to users.
FUNCTION OF APPLICATION LAYER
• Identifying communication partners: The application layer identifies the
availability of communication partners for an application with data to
transmit.
• Determining resource availability: The application layer determines
whether sufficient network resources are available for the requested
communication.
• Synchronizing communication: All the communications occur between
the applications requires cooperation which is managed by an application
layer.
• It handles issues such as network transparency, resource allocation and so
on.
• This layer serves as a window for users and application processes to access
network services.
• allows users to interact with other software applications.
APPLICATION OF APPLICATION LAYER
• Domain Name Server
• World Wide Web (WWW).
• E-MAIL
Services of Application Layers
• Network Virtual terminal
• File Transfer, Access, and Management
• Addressing
• Mail Service
Domain Name System
• In data networks, devices are assigned IP
addresses so that they can participate in
sending and receiving messages over the
network.
• On the Internet, these domain names, such as
[Link] are much easier for
people to remember than [Link],
How DNS Works
• The DNS protocol defines an automated service that
matches resource names with the required numeric
network address. It includes the format for queries,
responses, and data formats.
• DNS protocol communications use a single format
called a message. This message format is used for all
types of client queries and server responses, error
messages, and the transfer of resource record
information between servers.
Domain
• The following are examples of top-level
domains :
• .au: Australia
• .co: Colombia
• .com: A business or industry
• .jp: Japan
• .org: A nonprofit organization
WWW Service and HTTP
• When a web address (or URL) is typed into a
web browser, the web browser establishes a
connection to the web service running on the
server using HTTP.
• http: The protocol or scheme
• [Link]: The server name
E-Mail Services
• The exchange of computer-stored messages
from one user to one or more recipients via
the internet.
• E-mail is defined as the transmission of messages on the Internet. It is
one of the most commonly used features over communications
networks that may contain text, files, images, or other attachments.
Generally, it is information that is stored on a computer sent through a
network to a specified individual or group of individuals.
• Email messages are conveyed through email servers; it uses multiple
protocols within the TCP/IP suite. For example, SMTP is a protocol,
stands for simple mail transfer protocol and used to send messages
whereas other protocols IMAP or POP are used to retrieve messages
from a mail server. If you want to login to your mail account, you just
need to enter a valid email address, password, and the mail servers
used to send and receive messages.
• Although most of the webmail servers automatically configure your
mail account, therefore, you only required to enter your email address
and password. However, you may need to manually configure each
account if you use an email client like Microsoft Outlook or Apple Mail.
In addition, to enter the email address and password, you may also
need to enter incoming and outgoing mail servers and the correct port
numbers for each one.
SMTP
• SMTP: Simple Mail Transfer Protocol
• SMTP stands for Simple Mail Transfer Protocol. It is a
standard protocol on a TCP/IP network for sending emails
through servers from one computer to another computer. It
is a part of the application layer of the TCP/IP protocol,
which makes possible to send email messages over the
internet to one or more recipients. So, it is used when an
email is sent from an email client, such as Outlook Express
or Gmail, to the recipient using email servers.
• SMTP moves your email across networks through a process
called "store and forward." It works in coordination with
Mail Transfer Agent (MTA) to send you mail to the right
computer and email inbox. It decides how an email will
move from one computer's to another computer. The
message moves in steps from its origin to its destination,
and at each step, SMTP does its job.
• The working of SMTP is a three-step process and is based
on the client/server model. In the first step, an email server
sends the email (message) from an email client such as
Gmail, Outlook, etc., to an email server using SMTP; in the
second step, the email server using SMTP sends the email
to the receiving email server. In the third step, the receiver
server uses an email client to download incoming mail via
IMAP and place it in the inbox of the recipient.
POP3
• 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 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.
IMAP
• IMAP stands for Internet Message Access Protocol. It
is an application layer protocol which is used to
receive the emails from the mail server. It is the most
commonly used protocols like POP3 for retrieving
the emails.
• It also follows the client/server model. On one side,
we have an IMAP client, which is a process running
on a computer. On the other side, we have an IMAP
server, which is also a process running on another
computer. Both computers are connected through a
network.
THE ADVANTAGES AND DISADVANTAGES OF MAIL
Advantages Disadvantages
Free and easy to use Limited storage
Spam protection Advertising
Customization options Security concerns
Mobile access Lack of customization
Integration with other Google services Limited support
World wide web
• World Wide Web, which is also known as a Web, is
a collection of websites or web pages stored in
web servers and connected to local computers
through the internet. These websites contain text
pages, digital images, audios, videos, etc. Users can
access the content of these sites from any part of
the world over the internet using their devices
such as computers, laptops, cell phones, etc. The
WWW, along with internet, enables the retrieval
and display of text and media to your device.
• The building blocks of the Web are web pages which are
formatted in HTML and connected by links called "hypertext" or
hyperlinks and accessed by HTTP. These links are electronic
connections that link related pieces of information so that users
can access the desired information quickly. Hypertext offers the
advantage to select a word or phrase from text and thus to access
other pages that provide additional information related to that
word or phrase.
• A web page is given an online address called a Uniform Resource
Locator (URL). A particular collection of web pages that belong to
a specific URL is called a website,
e.g., [Link], [Link], etc. So, the World
Wide Web is like a huge electronic book whose pages are stored
on multiple servers across the world.
• Small websites store all of their WebPages on a single server, but
big websites or organizations place their WebPages on different
servers in different countries so that when users of a country
search their site they could get the information quickly from the
nearest server.
How the World Wide Web Works?
• Now, we have understood that WWW is a
collection of websites connected to the internet so
that people can search and share information.
Now, let us understand how it works!
• The Web works as per the internet's basic client-
server format as shown in the following image.
The servers store and transfer web pages or
information to user's computers on the network
when requested by the users. A web server is a
software program which serves the web pages
requested by web users using a browser. The
computer of a user who requests documents from
a server is known as a client. Browser, which is
installed on the user' computer, allows users to
view the retrieved documents.
• All the websites are stored in web servers. Just as
someone lives on rent in a house, a website occupies a
space in a server and remains stored in it. The server
hosts the website whenever a user requests its
WebPages, and the website owner has to pay the
hosting price for the same.
• The moment you open the browser and type a URL in
the address bar or search something on Google, the
WWW starts working. There are three main
technologies involved in transferring information (web
pages) from servers to clients (computers of users).
These technologies include Hypertext Markup
Language (HTML), Hypertext Transfer Protocol (HTTP)
and Web browsers.
Benefits of World Wide Web
• Reduces the cost of divulgation.
• Rapid interactive communication which can be used for
different services.
• Exchange of huge volumes of as well as establishment of
professional contact.
• Low cost of initial connection.
• Facilitates the establishment of professional contact.
• No barriers to divulgation.
• TWO TYPES OF WEBPAGE:
STATIC WEB
• Easier and cheaper to build and deploy
• Cheaper to host
• Faster load time
• Flexibility – every page can have different design
or layout
• DYNAMIC WEB:
• Offers greater degree of website functionality and
user interaction
• Connected to CMS and database – easily request
customized content in organized and structured
manner
• Much easier to update and maintain
HTTP:
• The Hypertext Transfer Protocol (HTTP) is the
foundation of the World Wide Web, and is used to
load webpages using hypertext links.
• HTTP stands for HyperText Transfer Protocol.
• It is a protocol used to access the data on the World
Wide Web (www).
• 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.