You are on page 1of 57

Transport

Layer

UNIT 5
Introduction
• The transport layer is responsible for process-to-
process delivery of the entire message.
• A process is an application program running on a host.
• Whereas the network layer oversees source-to-
destination delivery of individual packets, it does not
recognize any relationship between those packets.
• It treats each one independently, as though each piece
belonged to a separate message, whether or not it
does.
• 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.
Introduction
• Computers often run several programs at the same
time.
• For this reason, source- to-destination delivery
means delivery not only from one computer to the
next but also from a specific process on one
computer to a specific process on the other.
• The transport layer header must therefore include
a type of address called port addresses in the
Internet and TCP/IP protocol suite.
• A transport layer protocol can be either
connectionless or connection-oriented.
Introduction
• A connectionless transport layer treats each segment
as an independent packet and delivers it to the
transport layer at the destination machine.
• A connection-oriented transport layer makes a
connection with the transport layer at the destination
machine first before delivering the packets.
• After all the data is transferred, the connection is
terminated.
• In the transport layer, a message is normally divided
into transmittable segments.
• A connectionless protocol, such as UDP, treats each
segment separately.
• A connection- oriented protocol, such as TCP.
Process-to-Process Delivery
• The data link layer (Link Layer) is responsible for delivery of
frames between two neighboring nodes over a link. This is
called node-to-node delivery.
• The network layer (Internet Layer) is responsible for delivery
of datagrams between two hosts. This is called host-to-host
delivery.
• Communication on the Internet is not defined as the
exchange of data between two nodes or between two hosts.
• Real communication takes place between two processes
(application programs).
• We need process-to-process delivery.
• However, at any moment, several processes may be running
on the source host and several on the destination host.
Process-to-Process Delivery
• 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.
• The transport layer is responsible for process-to-
process delivery-the delivery of a packet, part of a
message, from one process to another.
• Two processes communicate in a client/server
relationship.
Process-to-Process Delivery
Client/Server Paradigm
• Although there are several ways to achieve process-to-
process communication, the most common one is
through the client/server paradigm.
• A process on the local host, called a client, needs
services from a process usually on the remote host,
called a server.
• Both processes (client and server) have the same name.
• For example, to get the day and time from a remote
machine, we need a Daytime client process running on
the local host and a Daytime server process running on
a remote machine.
Client/Server Paradigm
• Operating systems today support both multiuser
and multiprogramming environments.
• A remote computer can run several server
programs at the same time, just as local computers
can run one or more client programs at the same
time.
• For communication, we must define the following:
1. Local host
2. Local process
3. Remote host
4. Remote process
Addressing
• Whenever we need to deliver something to one
specific destination among many, we need an
address.
• At the data link layer, we need a MAC address, At
the network layer, we need an IP address.
• At the transport layer, we need a transport layer
address, called a port number, to choose among
multiple processes running on the destination host.
• The destination port number is needed for delivery;
the source port number is needed for the reply.
Addressing
• The port numbers are 16-bit integers between 0 and 65,535.
• The client program defines itself with a port number, chosen
randomly by the transport layer software running on the
client host. This is the ephemeral port number.
• The server process must also define itself with a port
number.
• This port number, however, cannot be chosen randomly.
• 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.
Addressing
• The port numbers are 16-bit integers between 0 and 65,535.
• The client program defines itself with a port number, chosen
randomly by the transport layer software running on the client
host. This is the ephemeral port number.
• The server process must also define itself with a port number.
• This port number, however, cannot be chosen randomly.
• 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.
• The Internet has decided to use universal port numbers for
servers; these are called well-known port numbers. Every client
process knows the well-known port number of the corresponding
server process. (Or at least the assigned Port No)
Addressing

It should be clear by now that the IP addresses and port numbers play different
roles in selecting the final destination of data. The destination IP address defines
the host among the different hosts in the world. After the host has been selected,
the port number defines one of the processes on this particular host
Addressing
• The lANA (Internet Assigned Number Authority) has divided the port
numbers into three ranges: well known, registered, and dynamic (or
private)
• Well-known ports. The ports ranging from 0 to 1023 are assigned and
controlled by lANA. These are the well-known ports.
• Registered ports. The ports ranging from 1024 to 49,151 are not
assigned or con- trolled by lANA. They can only be registered with lANA
to prevent duplication.
• Dynamic ports. The ports ranging from 49,152 to 65,535 are neither
controlled nor registered. They can be used by any process. These are
the ephemeral ports.
Addressing

TCP Well-known ports UDP Well-known ports


Socket
• Process-to-process delivery needs two identifiers, IP address and the
port number, at each end to make a connection.
• The combination of an IP address and a port number is called a socket
address.
• The client socket address defines the client process uniquely just as the
server socket address defines the server process uniquely
• A transport layer protocol needs a pair of socket addresses: the client
socket address and the server socket address.
• These four pieces of information are part of the IP header and the
transport layer protocol header.
• The IP header contains the IP addresses; the UDP or TCP header
contains the port numbers.
Socket
Multiplexing and Demultiplexing
• The addressing mechanism allows multiplexing and
demultiplexing by the transport layer
Multiplexing and Demultiplexing
Multiplexing
• At the sender site, there may be several processes that need
to send packets. However, there is only one transport layer
protocol at any time. This is a many-to-one relationship and
requires multiplexing. The protocol accepts messages from
different processes, differentiated by their assigned port
numbers. After adding the header, the transport layer
passes the packet to the network layer.
Demultiplexing
• At the receiver site, the relationship is one-to-many and
requires demultiplexing. The transport layer receives
datagrams from the network layer. After error checking and
dropping of the header, the transport layer delivers each
message to the appropriate process based on the port
number.
Connectionless Versus Connection-Oriented Service

A transport layer protocol can either be connectionless or


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

Connection-Oriented Service
• In a connection-oriented service, a connection is
first established between the sender and the
receiver.
• Data are transferred.
• At the end, the connection is released.
• TCP is a connection-oriented protocols.
Connection-Oriented TCP over Connectionless IP

How it works with TCP?


• TCP is connection oriented in the sense that there's a
connection establishment, between the two ends
where they may negotiate different things like
congestion-control mechanism among other things.
• The transport layer protocols' general purpose is to
provide process-to-process delivery meaning that it
doesn't know anything about routes; how your packets
reach the end system is beyond their scope, they're
only concerned with how packets are being transmitted
between the two end PROCESSES.
Connection-Oriented TCP over Connectionless IP

• IP, on the other hand, the Network layer protocol


for the Internet, is concerned with data-delivery
between end-systems yet it's connection-less,
• it maintains no connection so each packet is
handled independently of the other packets.
Leaving your system, each router will choose the
path that it sees fit for EACH packet, and this path
may change depending on availability/congestion.
Connection-Oriented TCP over Connectionless IP

• TCP will make sure packets reach the other process,


it won't care HOW they got there.
• IP, on the other hand, will not care if they reach the
other end at all, it'll simply forward each different
packet according to what it sees most fit for a
particular packet.
• Hence The TCP protocol deals with the problem of
IP packets arriving out of order or being lost, to give
you the feeling they arrive through a single FIFO
channel.
Reliable Versus Unreliable
• The transport layer service can be reliable or unreliable.
• If the application layer program needs reliability, we
use a reliable transport layer protocol by implementing
flow and error control at the transport layer.
• This means a slower and more complex service.
• 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.
Reliable Versus Unreliable
• On the Internet, there are different transport layer
protocols.
• UDP is connectionless and unreliable; TCP is
connection- oriented and reliable.
• These protocols respond to the demands of the
application layer programs.
• If the data link layer is reliable and has flow and error
control, do we need this at the transport layer, too?
• The answer is yes. Reliability at the data link layer is
between two nodes; we need reliability between two
ends.
• Because the network layer in the Internet is unreliable
Reliable Versus Unreliable
Importance of TCP/IP
• Transmission Control Protocol (TCP) and Internet
Protocol (IP) are the two most important lower-
level protocols enabling Internet connectivity.
• IP is responsible for moving packets of data from
one connection point to the next, while TCP verifies
the integrity of data traveling between two
endpoints.
• TCP and IP work together so much that the two
protocols are commonly referred to as TCP/IP.
Importance of TCP/IP
• Collectively, the TCP/IP suite of protocols is
classified as stateless, which means each client
request is considered new because it is unrelated
to previous requests.
• Being stateless frees up network paths so they can
be used continuously.
• The transport layer itself, however, is stateful.
• It transmits a single message, and its connection
remains in place until all the packets in a message
have been received and reassembled at the
destination.
Importance of TCP/IP
• TCP/IP is nonproprietary and, as a result, is not
controlled by any single company.
• Therefore, the IP suite can be modified easily. It is
compatible with all operating systems (OSes), so it can
communicate with any other system.
• The IP suite is also compatible with all types of
computer hardware and networks.
• TCP/IP is highly scalable and, as a routable protocol, can
determine the most efficient path through the
network.
• It is widely used in current internet architecture.
Importance of TCP/IP
• The Defense Advanced Research Projects Agency
(DARPA), the research branch of the U.S.
Department of Defense (DOD), created the TCP/IP
model in the 1970s for use in ARPANET, a wide area
network (WAN) that preceded the internet.
• TCP/IP was originally designed for the UnixOS, and
it has been built into all of the OSes that came after
it.
• The TCP/IP model and its related protocols are now
maintained by the Internet Engineering Task Force
(IETF).
1) USER DATAGRAM PROTOCOL (UDP)
• User Datagram Protocol (UDP) provides a way for applications to send
encapsulated IP datagrams without having to establish a connection.
• UDP transmits segments consisting of an 8-byte header followed by the
payload.
• The two ports serve to identify the endpoints within the source and
destination machines.
• When a UDP packet arrives, its payload is handed to the process attached
to the destination port.
• The main value of UDP over just using raw IP is the addition of the source
and destination ports.
• Without the port fields, the transport layer would not know what to do
with each incoming packet. With them, it delivers the embedded
segment to the correct application.

Computer
Communication Network
• Applications that use UDP:
• Streaming media (Streaming media is multimedia that is constantly received
by and presented to an end-user while being delivered by a provider),
e.g. RealAudio and RealVideo.
• VoIP e.g. Skype.
• Online multiplayer games
• DNS

Computer
Communication Network
Summary of fields in the UDP header

• Source Port = port number used to identify by the sender (user


program) on its computer
• Destination Port = port number used to identify by the receiver on
its computer
• Checksum = checksum to protect the UDP packet
• Packet Length = length of user data (in #bytes)

Computer
Communication Network
• The source port is primarily needed when a reply must be sent back
to the source.
• By copying the Source port field from the incoming segment into the
Destination port field of the outgoing segment, the process sending
the reply can specify which process on the sending machine is to get
it.

Computer
Communication Network
• The UDP length field includes the 8-byte header and the data. The
minimum length is 8 bytes, to cover the header.
• The maximum length is 65,515 bytes.
• An optional Checksum is also provided for extra reliability.

Computer
Communication Network
2) TRANSMISSION CONTROL PROTOCOL(TCP)
• TCP (Transmission Control Protocol) was specifically designed to provide
a reliable end-to-end byte stream over an unreliable internetwork.
• An internetwork differs from a single network because different parts
may have wildly different topologies, bandwidths, delays, packet sizes,
and other parameters.
• TCP was designed to dynamically adapt to properties of the internetwork
and to be robust in the face of many kinds of failures.
• Applications that use TCP:
• HTTP
• FTP
• telnet, ssh (Secure Socket Shell- is a UNIX-based command interface
and protocol for securely getting access to a remote computer)
• SMTP,POP3- Post Office Protocol version 3 (POP3)

Computer
Communication Network
• TCP service is obtained by both the sender and the receiver creating
end points, called sockets.
• Each socket has a socket number (address) consisting of the IP
address of the host and a 16-bit number local to that host, called a
port which is also known as TCP Service access point.
• Port numbers below 1024 are reserved for standard services that can
usually only be started by privileged users.
• They are called well-known ports. E.g. port number 20, 21 are
reserved for FTP, port no. 25 reserved for SMTP, port no. 80 is
reserved for HTTP etc.

Computer
Communication Network
• A key feature of TCP, and one that dominates the protocol design, is
that every byte on a TCP connection has its own 32-bit sequence
number.
• The sending and receiving TCP entities exchange data in the form of
segments.
• A TCP segment consists of a fixed 20-byte header (plus an optional
part) followed by zero or more data bytes.
• The TCP software decides how big segments should be.
• It can accumulate data from several writes into one segment or can
split data from one write over multiple segments.

Computer
Communication Network
The TCP header

Computer
Communication Network
Parts of the TCP Segment header:

• The Source port and Destination port fields identify the local end
points of the connection.
• The Sequence number field is used to indicate the sequence number
of the particular packet being sent.
• The Acknowledgement number field is used to indicate the
acknowledgement number of the packet that is expected by the
receiver.
• The TCP header length field tells how many 32-bit words are
contained in the TCP header.

Computer
Communication Network
• Eight 1-bit flags:
• CWR and ECE are used to signal congestion when ECN (Explicit Congestion
Notification) is used.
• ECE is set to signal an ECN-Echo to a TCP sender to tell it to slow down when
the TCP receiver gets a congestion indication from the network.
• CWR is set to signal Congestion Window Reduced from the TCP sender to the
TCP receiver so that it knows the sender has slowed down and can stop
sending the ECN-Echo.
• URG is set to 1 if the Urgent pointer is in use. The Urgent pointer is used to
indicate a byte offset from the current sequence number at which urgent
data are to be found. This facility is used mostly for interrupt messages.
• The ACK bit is set to 1 to indicate that the Acknowledgement number is valid.
This is the case for nearly all packets. If ACK is 0, the segment does not
contain an acknowledgement, so the Acknowledgement number field is
ignored.
• The PSH bit indicates PUSHed data. The receiver is hereby kindly requested
to deliver the data to the application upon arrival and not buffer it until a full
buffer has been received.
• The RST bit is used to abruptly reset a connection that has become confused
due to a host crash or some other reason. It is also used to reject an invalid
segment or refuse an attempt to open a connection.
• The SYN bit is used to establish connections.
• The FIN bit is used to release a connection.
Computer
Communication Network
Parts of the TCP Segment header:

• The Window size field tells how many bytes may be sent starting at
the byte acknowledged. Used to set the number of segments that
can be sent before waiting for a confirmation from the destination.
• A Checksum is also provided for extra reliability. CRC (cyclic
redundancy check) of the header and data piece.
• The Options field provides a way to add extra facilities not covered by
the regular header. Used to define any additional options such as
maximum segment size

Computer
Communication Network
TCP Options

• A widely used option is the one that allows each host to specify the
MSS (Maximum Segment Size) it is willing to accept.
• The window scale option allows the sender and receiver to negotiate
a window scale factor at the start of a connection.
• The timestamp option carries a timestamp sent by the sender and
echoed by the receiver.
• SACK (Selective ACKnowledgement) option lets a receiver tell a
sender the ranges of sequence numbers that it has received.

Computer
Communication Network
TCP Connection Establishment

• TCP connections are established via an exchange known as the three-


way handshake.
• If A is the client and B is the LISTENing server, then the handshake
proceeds as follows:
• A sends B a packet with the SYN bit set (a SYN packet)
• B responds with a SYN packet of its own; the ACK bit is now also set
• A responds to B’s SYN with its own ACK
TCP Connection Establishment

• Step 1 (SYN) : In the first step, client wants to establish a connection with
server, so it sends a segment with SYN(Synchronize Sequence Number)
which informs server that client is likely to start communication and with
what sequence number it starts segments with
• Step 2 (SYN + ACK): Server responds to the client request with SYN-ACK
signal bits set. Acknowledgement(ACK) signifies the response of segment it
received and SYN signifies with what sequence number it is likely to start the
segments with
• Step 3 (ACK) : In the final part client acknowledges the response of server
and they both establish a reliable connection with which they will start the
actual data transfer. The steps 1, 2 establish the connection parameter
(sequence number) for one direction and it is acknowledged. The steps 2, 3
establish the connection parameter (sequence number) for the other
direction and it is acknowledged. With these, a full-duplex communication is
established.
Closing a TCP connection

• TCP supports two types of connection releases like most connection-


oriented transport protocols:
• Graceful connection release –
In Graceful connection release, the connection is open until both
parties have closed their sides of the connection.
• Abrupt connection release –
In Abrupt connection release, either one TCP entity is forced to close
the connection or one user closes both directions of data transfer.
Abrupt connection release

• An abrupt connection release is carried out when a RST segment is


sent. A RST segment can be sent for the below reasons:
1. When a non-SYN segment was received for a non-existing TCP
connection.
2. In an open connection, some TCP implementations send a RST
segment when a segment with an invalid header is received. This
will prevent attacks by closing the corresponding connection.
3. When some implementations need to close an existing TCP
connection, they send a RST segment. They will close an existing
TCP connection for the following reasons:
• Lack of resources to support the connection
• The remote host is now unreachable and has stopped responding.
Graceful Connection Release
Graceful Connection Release

• Step 1 (FIN From Client) –


Suppose that the client application decides it wants to close the connection.
This causes the client to send a TCP segment with the FIN bit set to 1 to
server and to enter the FIN_WAIT_1 state. While in the FIN_WAIT_1 state,
the client waits for a TCP segment from the server with an acknowledgment
(ACK).
• Step 2 (ACK From Server) –
When Server received FIN bit segment from Sender (Client), Server
Immediately send acknowledgement (ACK) segment to the Sender (Client).
• Step 3 (Client waiting) –
While in the FIN_WAIT_1 state, the client waits for a TCP segment from the
server with an acknowledgment. When it receives this segment, the client
enters the FIN_WAIT_2 state. While in the FIN_WAIT_2 state, the client
waits for another segment from the server with the FIN bit set to 1.
Graceful Connection Release

• Step 4 (FIN from Server) –


Server sends FIN bit segment to the Sender(Client) after some time
when Server send the ACK segment (because of some closing process
in the Server).
• Step 5 (ACK from Client) –
When Client receive FIN bit segment from the Server, the client
acknowledges the server’s segment and enters the TIME_WAIT state.
The TIME_WAIT state lets the client resend the final
acknowledgment in case the ACK is lost.
• The time spent by client in the TIME_WAIT state is depend on their
implementation, but their typical values are 30 seconds, 1 minute,
and 2 minutes. After the wait, the connection formally closes and all
resources on the client side (including port numbers and buffer data)
are released.
UDP Connections

• Unlike TCP, it is unreliable and connectionless protocol.


• So, there is no need to establish connection prior to data transfer.
• It works on the concept of REQUEST and RESPONSE
• It has no handshaking dialogues, and thus exposes the user's
program to any unreliability of the underlying network; there is no
guarantee of delivery, ordering, or duplicate protection.

You might also like