You are on page 1of 56

Data communication and Computer network

Chapter 3
Transport Layer

10/11/2023 Compiled by: - Jarso D. 1


Chapter Outline
o Transport Layer overview
o Multiplexing and DE-multiplexing
o Segmentation
o Transport Layer Addressing
o Connectionless/Connection-Oriented
o Unreliable/ Reliable
o Protocols in Transport Layer

10/11/2023 Compiled by: - Jarso D. 2


Layer 4. Transport layer (4th OSI layer)
o The transport layer is responsible for process-to-
process delivery of the entire message.
o A process is an application program running on a
host.
o Whereas the network layer oversees source-to-
destination delivery of individual packets, it does not
recognize any relationship between those packets.
o The network layer treats each packet independently,
as though each piece belonged to a separate message,
whether or not it does.
o The transport layer, on the other hand, ensures that
the whole message arrives intact and in order,
overseeing both error control and flow control at the
source-to-destination level.
10/11/2023 Compiled by: - Jarso D. 3
Major functions of the transport layer
o The Transport layer encompasses these
functions:
o Enables multiple applications to communicate over
the network at the same time on a single device
o Ensures that, if required, all the data is received
reliably and in order by the correct application
o Employs error handling mechanisms

10/11/2023 Compiled by: - Jarso D. 4


Cont.

10/11/2023 Compiled by: - Jarso D. 5


Multiplexing
o In data communication, there might be a need to
share a single media for multiple communication
(media/bandwidth sharing) in order to utilize the
available bandwidth wisely to achieve specific goals.
o Sharing of a single media (fiber, coaxial,
microwave,..) is known as multiplexing.
o Multiplexing is the set of techniques that allows the
(simultaneous) transmission of multiple signals
across a single data link.
o As data and telecommunications use increases, so
does traffic.
10/11/2023 Compiled by: - Jarso D. 6
Cont.

10/11/2023 Compiled by: - Jarso D. 7


Cont.
o The link is able to carry n separate channels of
data.
o The multiplexer combines (multiplexes) data
from the n input lines and transmits over a higher
capacity data link.
o The de-multiplexer accepts the multiplexed data
stream, separates (de-multiplexes) the data
according to channel, and delivers them to the
appropriate output lines.

10/11/2023 Compiled by: - Jarso D. 8


Cont.
o There are three types of Multiplexing

10/11/2023 Compiled by: - Jarso D. 9


Frequency-division Multiplexing (FDM)
o FDM is a signal transmission technology in
which multiple signals can simultaneously be
transmitted over the same line or channel.
o Frequency-division multiplexing (FDM) can be
used in both wired and wireless networking for
transmitting large amounts of data at high speeds.
o FDM is the simplest and oldest form of
multiplexing in wireless networking technology.
o Frequency division multiplexing involves
simultaneously transmitting multiple signals on
different frequencies.
10/11/2023 Compiled by: - Jarso D. 10
Cont.
o These different frequencies, called channels,
share non-overlapping portions of the total
frequency band being used.
o Signals from different data sources are fed into a
multiplexer that modulates each signal and
transmits them at different frequencies.
o These signals are then transmitted over the wire
or through wireless communication and are
separated at the destination into individual data
signals using a demultiplexer.
10/11/2023 Compiled by: - Jarso D. 11
Cont.
FD Multiplexing Vs. FD Demultiplexing Example

10/11/2023 Compiled by: - Jarso D. 12


Time-division multiplexing (TDM)
o A multiplexing method for transmitting multiple
data streams in a single communication path.
o In TDM, the data from different input channels is
divided into fixed-length segments and then
combined in round-robin fashion into a single
output data stream, which can then be transmitted
over a single channel transmission system and de-
multiplexed at the destination location.
o The segments can be created by the multiplexer
itself or can be inherent in the input channel
signals, such as fixed-length frames.
10/11/2023 Compiled by: - Jarso D. 13
Cont.
o TDM is a digital multiplexing technique for
combining several low-rate digital channels into one
high-rate one.
o One weakness in TDM is that if an input channel
does not have anything important to carry for a time,
empty segments are inserted into the output stream
anyway.
o For example, if channel A is not transmitting data,
one-third of the output channel is not being used.
o You can overcome this weakness by using a more
sophisticated multiplexing technique called
statistical multiplexing.

10/11/2023 Compiled by: - Jarso D. 14


Cont.

10/11/2023 Compiled by: - Jarso D. 15


Statistical Multiplexing
o It is a multiplexing technique that allows information
from a number of channels to be combined for
transmission over a single channel.
o Statistical multiplexing dynamically allocates
bandwidth to each channel on an as-needed basis.
o This is in contrast to time-division multiplexing
(TDM) techniques, in which quiet devices use up a
portion of the multiplexed data stream, filling it with
empty packets.
o Statistical multiplexing allocates bandwidth only to
channels that are currently transmitting.

10/11/2023 Compiled by: - Jarso D. 16


Cont.
o It packages the data from the active channels
into packets and dynamically feeds them into the
output channel, usually on a FIFO (first in, first
out) basis, but it’s also able to allocate extra
bandwidth to specific input channels.
o Statistical multiplexing is sometimes referred to
as statistical time-division multiplexing (STDM)

10/11/2023 Compiled by: - Jarso D. 17


Cont.

10/11/2023 Compiled by: - Jarso D. 18


Cont.
o In addition to multiplexing other responsibilities
of transport layer include the following:
o Service-point addressing:- Computers often run
several programs at the same time.
o For this reason, source-to-destination delivery means
delivery not only from one computer to the next but
also from a specific process (running program) on
one computer to a specific process on the other.
o The transport layer header must therefore include a
type of address called a service-point address (or
port address).

10/11/2023 Compiled by: - Jarso D. 19


Cont.
o The network layer gets each packet to the correct
computer; the transport layer gets the entire message to
the correct process on that computer.
o Segmentation and reassembly:- A message is
divided into transmittable segments, with each
segment containing a sequence number.
o These numbers enable the transport layer to
reassemble the message correctly upon arriving at
the destination and to identify and replace packets
that were lost in transmission.

10/11/2023 Compiled by: - Jarso D. 20


Cont.
o Flow control:- Like the data link layer, the transport
layer is responsible for flow control.
o However, flow control at this layer is performed end
to end rather than across a single link.
o Error control:- Like the data link layer, the transport
layer is responsible for error control.
o However, error control at this layer is performed
process-to-process rather than across a single link.
o The sending transport layer makes sure that the entire
message arrives at the receiving transport layer
without error (damage, loss, or duplication).
o Error correction is usually achieved through
retransmission.
10/11/2023 Compiled by: - Jarso D. 21
Cont.
o Connection control:- The transport layer can be
either connectionless or connection-oriented.
o Connectionless transport layer treats each segment
as an independent packet and delivers it to the
transport layer at the destination machine.
o Connection-oriented transport layer makes a
connection with the transport layer at the
destination machine first before delivering the
packets.
o After all the data are transferred, the connection is
terminated.
10/11/2023 Compiled by: - Jarso D. 22
Process-to-Process Delivery
o Communication on the Internet is not defined as
the exchange of data between two nodes or
between two hosts.
o Real communication takes place between two
processes (application programs).
o We need process-to-process delivery.

10/11/2023 Compiled by: - Jarso D. 23


Cont.
o However, at any moment, several processes may be
running on the source host and several on the
destination host.
o To complete the delivery, we need a mechanism to
deliver data from one of these processes running on
the source host to the corresponding process running
on the destination host.
o The transport layer is responsible for process-to-
process delivery-the delivery of a packet, part of a
message, from one process to another.
o Two processes communicate in a client/server
relationship.
10/11/2023 Compiled by: - Jarso D. 24
Transport layer addressing
o Whenever we need to deliver something to one
specific destination among many, we need an
address.
o At the transport layer, we need a transport layer
address, called a port number, to choose among
multiple processes running on the destination
host.

10/11/2023 Compiled by: - Jarso D. 25


Cont.
o The destination port number is needed for
delivery; the source port number is needed for the
reply.
o In the Internet model, the port numbers are 16-bit
integers between 0 and 65,535.
o The client program defines itself with a port
number, chosen randomly by the transport layer
software running on the client host.
o This is the ephemeral (temporal) port number.
(next slide, more on port number)

10/11/2023 Compiled by: - Jarso D. 26


Cont.
o The server process must also define itself with a
port number.
o This port number, however, cannot be chosen
randomly.
o If the computer at the server site runs a server
process and assigns a random number as the port
number, the process at the client site that wants to
access that server and use its services will not
know the port number.

10/11/2023 Compiled by: - Jarso D. 27


Cont.
o Of course, one solution would be to send a
special packet and request the port number of a
specific server, but this requires more overhead.
o The Internet has decided to use universal port
numbers for servers; these are called well-known
port numbers.
o Example of well known port numbers: 21 for
FTP, 23 telnet, 25 SMTP, 80 HTTP, etc

10/11/2023 Compiled by: - Jarso D. 28


Internet Assigned Number Authority (IANA) Ranges
o There are some exceptions to this rule; for
example, there are clients that are assigned well-
known port numbers.
o Every client process knows the well-known port
number of the corresponding server process.
o Well-known ports: - the ports ranging from 0 to
1023 are assigned and controlled by IANA.
o These are the well-known ports.

10/11/2023 Compiled by: - Jarso D. 29


Cont.
o Registered ports: - the ports ranging from 1024 to
49,151 are not assigned or controlled by IANA.
o They can only be registered with IANA to prevent
duplication.
o Dynamic ports: - the ports ranging from 49,152 to
65,535 are neither controlled nor registered.
o They can be used by any process.
o These are the ephemeral ports (temporary ports).

10/11/2023 Compiled by: - Jarso D. 30


Socket Addresses
o Process-to-process delivery needs two identifiers,
IP address and the port number, at each end to
make a connection.
o The combination of an IP address and a port
number is called a socket address.
o The client socket address defines the client
process uniquely just as the server socket address
defines the server process uniquely.

10/11/2023 Compiled by: - Jarso D. 31


Cont.
o A transport layer protocol needs a pair of socket
addresses: the client socket address and the server
socket address.
o These four pieces of information are part of the IP
header and the transport layer protocol header.
o The IP header contains the IP addresses; the UDP
or TCP header contains the port numbers.

10/11/2023 Compiled by: - Jarso D. 32


Connectionless Versus Connection-Oriented Service
o A transport layer protocol can either be
connectionless or connection-oriented.
Connectionless Service
o In a connectionless service, the packets are sent
from one party to another with no need for
connection establishment or connection release.
o The packets are not numbered; they may be
delayed or lost or may arrive out of sequence.
o There is no acknowledgment either.

10/11/2023 Compiled by: - Jarso D. 33


Cont.
o UDP is connectionless.
Connection-Oriented Service
o In a connection-oriented service, a connection is
first established between the sender and the
receiver.
o Data are transferred.
o At the end, the connection is released.
o TCP and SCTP are connection-oriented protocols.

10/11/2023 Compiled by: - Jarso D. 34


Reliable Versus Unreliable
o The transport layer service can be reliable or unreliable.
o If the application layer program needs reliability, we use
a reliable transport layer protocol by implementing flow
and error control at the transport layer.
o This means a slower and more complex service.
o On the other hand, if the application program does not
need reliability because it uses its own flow and error
control mechanism or it needs fast service or the nature
of the service does not demand flow and error control
(real-time applications), then an unreliable protocol can
be used.

10/11/2023 Compiled by: - Jarso D. 35


Cont.
o In the Internet, there are two common different
transport layer protocols, as we have already
mentioned.
o UDP is connectionless and unreliable; TCP and
SCTP are connection-oriented and reliable
protocols.
o These three can respond to the demands of the
application layer programs.

10/11/2023 Compiled by: - Jarso D. 36


User datagram protocol (UDP)
o The User Datagram Protocol (UDP) is called a
connectionless, unreliable transport protocol.
o It does not add anything to the services of IP
except to provide process-to-process
communication.
o Also, it performs very limited error checking.
o If UDP is so powerless, why would a process want
to use it?
o With the disadvantages come some advantages.

10/11/2023 Compiled by: - Jarso D. 37


Cont.
o UDP is a very simple protocol using a minimum
of overhead.
o If a process wants to send a small message and
does not care much about reliability, it can use
UDP.
o Sending a small message by using UDP takes
much less interaction between the sender and
receiver than using TCP or SCTP.

10/11/2023 Compiled by: - Jarso D. 38


Cont.
o UDP packets, called user datagrams, have a
fixed-size header of 8 bytes
o Source port number. This is the port number used
by the process running on the source host.
o Destination port number. This is the port number
used by the process running on the destination
host.
o Length. This is a 16-bit field that defines the total
length of the user datagram, header plus data.

10/11/2023 Compiled by: - Jarso D. 39


Cont.
o UDP does not perform:
o Flow control
o Error control
o Connection control
o All these functions are done by the processes (application
layer programs) using UDP
o UDP is not capable of segmenting and reassembling frames
and does not implement sequence numbers
o But UDP, like TCP, performs:
o Service point addressing
o UDP can transmit only small portions of data at a time
because it is not capable of segmenting and reassembling
frames and does not implement sequence numbers.

10/11/2023 Compiled by: - Jarso D. 40


Use of UDP
o UDP is suitable for a process that requires simple
request-response communication with little concern for
flow and error control.
o It is not usually used for a process such as FTP that
needs to send bulk data
o UDP is suitable for a process with internal flow and
error control mechanisms.
o For example, the Trivial File Transfer Protocol (TFTP)
process includes flow and error control. It can easily
use UDP.
o UDP is a suitable transport protocol for multicasting.
o Multicasting capability is embedded in the UDP
software but not in the TCP software.
o UDP is used for management processes such as SNMP.
o UDP is used for some route updating protocols such as
Routing Information Protocol
10/11/2023
(RIP).
Compiled by: - Jarso D. 41
Transmission Control Protocol (TCP)
o TCP, like UDP, is a process-to-process (program-to-
program) protocol.
o TCP, therefore, like UDP, uses port numbers. Unlike
UDP, TCP is a connection-oriented protocol; it
creates a virtual connection between two TCPs to
send data.
o In addition, TCP uses flow and error control
mechanisms at the transport level.
o In brief, TCP is called a connection-oriented, reliable
transport protocol.
o It adds connection-oriented and reliability features to
the services of IP.
10/11/2023 Compiled by: - Jarso D. 42
TCP Services
o Process-to-Process Communication:- Like
UDP, TCP provides process-to-process
communication using port numbers.
o Stream Delivery Service
o Full-Duplex Communication
o Connection-Oriented Service
o Reliable Service

10/11/2023 Compiled by: - Jarso D. 43


Connection-Oriented Service
o TCP, unlike UDP, is a connection-oriented protocol.
o When a process at site A wants to send and receive data from
another process at site B, the following occurs:
o The two TCPs establish a connection between them.
o Data are exchanged in both directions.
o The connection is terminated.
o Note that this is a virtual connection, not a physical connection.
o The TCP segment is encapsulated in an IP datagram and can be
sent out of order, or lost, or corrupted, and then resent.
o Each may use a different path to reach the destination. There is no
physical connection.
o TCP creates a stream-oriented environment in which it accepts the
responsibility of delivering the bytes in order to the other site.

10/11/2023 Compiled by: - Jarso D. 44


TCP Segment Numbering System
o Byte Number TCP numbers all data bytes that are
transmitted in a connection.
o Numbering is independent in each direction.
o When TCP receives bytes of data from a process, it
stores them in the sending buffer and numbers them.
o The numbering does not necessarily start from 0.
o Instead, TCP generates a random number between 0
and 232 - 1 for the number of the first byte.
o For example, if the random number happens to be
1057 and the total data to be sent are 6000 bytes, the
bytes are numbered from 1057 to 7056.
10/11/2023 Compiled by: - Jarso D. 45
Cont.
o Byte numbering is used for flow and error control
too.
o Sequence Number After the bytes have been
numbered, TCP assigns a sequence number to
each segment that is being sent.
o The sequence number for each segment is the
number of the first byte carried in that segment.

10/11/2023 Compiled by: - Jarso D. 46


Quiz
o Suppose a TCP connection is transferring a file of
8000 bytes. The first byte is numbered 10,001. What
are the sequence numbers for each segment if data are
sent in four segments, each carrying 2000 bytes?
o Solution

 SeThe following shows the sequence number for each segment:

 gment 1 Sequence Number: 10,001 (range: 10,001 to 12,000)

 Segment 2 Sequence Number: 12,001 (range: 12,001 to 14,000)

 Segment 3 Sequence Number: 14,001 (range: 14,001 to 16,000)

 Segment 4 Sequence Number: 16,001 (range: 16,001 to 18,000)

10/11/2023 Compiled by: - Jarso D. 47


Three-Way Handshaking in connection establishment
o The connection establishment in TCP is called three-
way handshaking.
o An application program, called the client, wants to
make a connection with another application program,
called the server, using TCP as the transport layer
protocol.
o The process starts with the server. The server
program tells its TCP that it is ready to accept a
connection.
o This is called a request for a passive open.
o Although the server TCP is ready to accept any
connection from any machine in the world, it cannot
make the connection itself.

10/11/2023 Compiled by: - Jarso D. 48


Cont.
o The client program issues a request for an active
open. A client that wishes to connect to an open
server tells its TCP that it needs to be connected to
that particular server.
o TCP can now start the three-way handshaking
process as shown in the figure in next slide.
o To show the process, we use two time lines: one at
each site. Each segment has values for all its header
fields and perhaps for some of its option fields, too.
o However, we show only the few fields necessary to
understand each phase.
o We show the sequence number, the acknowledgment
number, the control flags (only those that are set),
and the window size, if not empty.
10/11/2023 Compiled by: - Jarso D. 49
The three steps in this phase are as follows.
o The client sends the first segment, a SYN segment, in
which only the SYN flag is set. This segment is for
synchronization of sequence numbers. It consumes one
sequence number.
o When the data transfer starts, the sequence number is
incremented by 1.
o We can say that the SYN segment carries no real data, but
we can think of it as containing 1 imaginary byte.
o The server sends the second segment, a SYN +ACK
segment, with 2 flag bits set: SYN and ACK.
o This segment has a dual purpose. It is a SYN segment for
communication in the other direction and serves as the
acknowledgment for the SYN segment.
o It consumes one sequence number.

10/11/2023 Compiled by: - Jarso D. 50


Cont.
o The client sends the third segment. This is just an
ACK segment.
o It acknowledges the receipt of the second segment
with the ACK flag and acknowledgment number
field.
o Note that the sequence number in this segment is
the same as the one in the SYN segment; the ACK
segment does not consume any sequence
numbers.

10/11/2023 Compiled by: - Jarso D. 51


Data Transfer
o After connection is established, bidirectional data
transfer can take place.
o The client and server can both send data and
acknowledgments.
o Data and acknowledgment traveling in the same
direction are carried on the same segment.
o The acknowledgment is piggybacked with the data.
In the example next slide, after connection is
established (not shown in the figure), the client sends
2000 bytes of data in two segments.
o The server then sends 2000 bytes in one segment.
The client sends one more segment.
10/11/2023 Compiled by: - Jarso D. 52
Cont.
o The first three segments carry both data and
acknowledgment, but the last segment carries only an
acknowledgment because there are no more data to
be sent.
o Note the values of the sequence and acknowledgment
numbers.
o The data segments sent by the client have the PSH
(push) flag set so that the server TCP knows to
deliver data to the server process as soon as they are
received.
o Connection Termination
o Any of the two parties involved in exchanging data
(client or server) can close the connection, although it
is usually initiated by the client.
10/11/2023 Compiled by: - Jarso D. 53
Three-Way Handshaking for connection termination
o In a normal situation, the client TCP, after receiving a close
command from the client process, sends the first segment, a FIN
segment in which the FIN flag is set.
o Note that a FIN segment can include the last chunk of data sent
by the client, or it can be just a control segment.
o If it is only a control segment, it consumes only one sequence
number.
o The server TCP, after receiving the FIN segment, informs its
process of the situation and sends the second segment, a FIN
+ACK segment, to confirm the receipt of the FIN segment from
the client and at the same time to announce the closing of the
connection in the other direction.
o This segment can also contain the last chunk of data from the
server.
o If it does not carry data, it consumes only one sequence number.

10/11/2023 Compiled by: - Jarso D. 54


Cont.
o The client TCP sends the last segment, an ACK
segment, to confirm the receipt of the FIN
segment from the TCP server.
o This segment contains the acknowledgment
number, which is 1 plus the sequence number
received in the FIN segment from the server.
o This segment cannot carry data and consumes no
sequence numbers.

10/11/2023 Compiled by: - Jarso D. 55


The End!

10/11/2023 Compiled by: - Jarso D. 56

You might also like