You are on page 1of 18

Unit III Transport Layer

Transport Layer: Relationship Between Transport and Network Layer, TCP and UDP; Multiplexing and
Demultiplexing; Principles of Reliable Data Transfer; Go-Back-N and Selective Repeat; TCP: Segment
Structure, Round Trip Time Estimation, Reliable Data Transfer, Flow Control, Congestion Control,UDP:
Segment Structure

Relationship between transport and Network Layer

From the perspective of network applications, the transport layer is the underlying
communication infrastructure. Of course, there is more to the communication infrastructure than
just the transport layer. For example, the network layer lies just below the transport layer in the
protocol stack. Whereas a transport layer protocol provides logical communication between
processes running on different hosts, a network layer protocol provides logical communication
between hosts. This distinction is subtle but important. Let's examine this distinction with the aid
of a household analogy.

Consider two houses, one on the East Coast and the other on the West Coast, with each house
being home to a dozen kids. The kids in the East Coast household are cousins with the kids in the
West Coast households. The kids in the two households love to write each other -- each kid
writes each cousin every week, with each letter delivered by the traditional postal service in a
separate envelope. Thus, each household sends 144 letters to the other household every week.
(These kids would save a lot of money if they had e-mail!). In each of the households there is
one kid -- Alice in the West Coast house and Bob in the East Coast house -- responsible for mail
collection and mail distribution. Each week Alice visits all her brothers and sisters, collects the
mail, and gives the mail to a postal-service mail person who makes daily visits to the house.
When letters arrive to the West Coast house, Alice also has the job of distributing the mail to her
brothers and sisters. Bob has a similar job on the East coast.

In this example, the postal service provides logical communication between the two houses --
the postal service moves mail from house to house, not from person to person. On the other hand,
Alice and Bob provide logical communication between the cousins -- Alice and Bob pick up
mail from and deliver mail to, their brothers and sisters. Note that, from the cousins' perspective,
Alice and Bob are the mail service, even though Alice and Bob are only a part (the end system
part) of the end-to-end delivery process. This household example serves as a nice analogy for
explaining how the transport layer relates to the network layer:

 hosts (also called end systems) = houses


 processes = cousins
 application messages = letters in envelope
 network layer protocol = postal service (including mail persons)
 transport layer protocol = Alice and Bob

Continuing with this analogy, observe that Alice and Bob do all their work within their
respective homes; they are not involved, for example, in sorting mail in any intermediate mail
center or in moving mail from one mail center to another. Similarly, transport layer protocols
live in the end systems. Within an end system, a transport protocol moves messages from
application processes to the network edge (i.e., the network layer) and vice versa; but it doesn't
have any say about how the messages are moved within the network core in intermediate routers
Unit III Transport Layer

neither act on, nor recognize, any information that the transport layer may have appended to the
application messages.

Continuing with our family saga, suppose now that when Alice and Bob go on vacation,
another cousin pair -- say, Susan and Harvey -- substitute for them and provide the household-
internal collection and delivery of mail. Unfortunately for the two families, Susan and Harvey do
not do the collection and delivery in exactly the same way as Alice and Bob. Being younger kids,
Susan and Harvey pick up and drop off the mail less frequently and occasionally lose letters
(which are sometimes chewed up by the family dog). Thus, the cousin-pair Susan and Harvey do
not provide the same set of services (i.e., the same service model) as Alice and Bob. In an
analogous manner, a computer network may make available multiple transport protocols, with
each protocol offering a different service model to applications.

The possible services that Alice and Bob can provide are clearly constrained by the
possible services that the postal service provides. For example, if the postal service doesn't
provide a maximum bound on how long it can take to deliver mail between the two houses (e.g.,
three days), then there is no way that Alice and Bob can guarantee a maximum delay for mail
delivery between any of the cousin pairs. In a similar manner, the services that a transport
protocol can provide are often constrained by the service model of the underlying network-layer
protocol.

Responsobilities of 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.
 The transport layer provides a logical communication between application processes
running on different hosts. Although the application processes on different hosts are not
physically connected, application processes use the logical communication provided by
the transport layer to send the messages to each other.
 The transport layer protocols are implemented in the end systems but not in the network
routers.
 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.
 All transport layer protocols provide multiplexing/demultiplexing service. It also
provides other services such as reliable data transfer, bandwidth guarantees, and delay
guarantees.
 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 process.
Unit III Transport Layer

Services provided by the Transport Layer


The services provided by the transport layer are similar to those of the data link layer. The data
link layer provides the services within a single network while the transport layer provides the
services across an internetwork made up of many networks. The data link layer controls the
physical layer while the transport layer controls all the lower layers.

The services provided by the transport layer protocols can be divided into five categories:

 End-to-end delivery
 Addressing
 Reliable delivery
 Flow control
 Multiplexing
Unit III Transport Layer

End-to-end delivery:
The transport layer transmits the entire message to the destination. Therefore, it ensures the end-
to-end delivery of an entire message from a source to the destination.

Reliable delivery:

The transport layer provides reliability services by retransmitting the lost and damaged packets.

TCP Protocol:

TCP (Transmission Control Protocol) is one of the main protocols of the Internet protocol suite. It lies
between the Application and Network Layers which are used in providing reliable delivery services. It is a
connection-oriented protocol for communications that helps in the exchange of messages between
different devices over a network. The Internet Protocol (IP), which establishes the technique for sending
data packets between computers, works with TCP.

To make sure that each message reaches its target location intact, the TCP/IP model breaks down
the data into small bundles and afterward reassembles the bundles into the original message on
the opposite end. Sending the information in little bundles of information makes it simpler to
maintain efficiency as opposed to sending everything in one go.

After a particular message is broken down into bundles, these bundles may travel along multiple
routes if one route is jammed but the destination remains the same.
Unit III Transport Layer

Features of TCP/IP

Some of the most prominent features of Transmission control protocol are

1. Segment Numbering System

 TCP keeps track of the segments being transmitted or received by assigning numbers to each
and every single one of them.
 A specific Byte Number is assigned to data bytes that are to be transferred while segments are
assigned sequence numbers.
 Acknowledgment Numbers are assigned to received segments.

2. Flow Control

 Flow control limits the rate at which a sender transfers data. This is done to ensure reliable
delivery.
 The receiver continually hints to the sender on how much data can be received (using a sliding
window)

3. Error Control

 TCP implements an error control mechanism for reliable data transfer


 Error control is byte-oriented
 Segments are checked for error detection
 Error Control includes – Corrupted Segment & Lost Segment Management, Out-of-order
segments, Duplicate segments, etc.

4. Congestion Control

 TCP takes into account the level of congestion in the network


 Congestion level is determined by the amount of data sent by a sender

Advantages

 It is a reliable protocol.
 It provides an error-checking mechanism as well as one for recovery.
 It gives flow control.
 It makes sure that the data reaches the proper destination in the exact order that it was sent.
 Open Protocol, not owned by any organization or individual.
 It assigns an IP address to each computer on the network and a domain name to each site thus
making each device site to be distinguishable over the network.

Disadvantages

 TCP is made for Wide Area Networks, thus its size can become an issue for small networks with
low resources.
Unit III Transport Layer

 TCP runs several layers so it can slow down the speed of the network.
 It is not generic in nature. Meaning, it cannot represent any protocol stack other than the TCP/IP
suite. E.g., it cannot work with a Bluetooth connection.
 No modifications since their development around 30 years ago.

TCP Connection

TCP establishes a secure and reliable connection between two devices. And this is possible because of
the TCP's 3-way handshake process, which occurs when two devices establish and close connections.
There are three steps to both establishing and closing the connection, as the name implies. So, in this
article, we'll go through the TCP 3-way handshake process and the various steps that it includes.

The 3-Way handshake is a TCP/IP network connection mechanism that connects the server and
client. Before the real data communication process begins, both the client and server must
exchange synchronization and acknowledgment packets.

The 3-way handshake mechanism is designed to allow both communicating ends to initiate and
negotiate the network TCP socket connection parameters at the same time before data is
transmitted. It allows you to transfer numerous TCP socket connections in both directions
simultaneously.

TCP Segment Structure


Every TCP segment consists of a data field and a header field, as shown below:

TCP Header
Unit III Transport Layer

A TCP segment's header field can be anything from 20 to 60 bytes long. Here 40 bytes are used
for the options field, which is located at the end of the TCP header. A header is 20 bytes if there
are no options field; otherwise, it can be up to 60 bytes.

 Source port- It is a 16-bit field that holds the port address of the application sending the
data.
 Destination Port- It is a 16-bit field that holds the port address of the application
receiving the data.
 Sequence Number- It is used to keep track of the bytes sent. Each byte in a TCP stream
is uniquely identified by the TCP sequence number, which is a four-byte number.
 Acknowledgment number- It is a 32-bit field that contains the acknowledgment number
or the byte number that the receiver expects to receive next. It works as an
acknowledgment for the previous data received successfully.
 Header Length (HLEN)- The header length is a 4-bit field that specifies the length of
the TCP header. It helps in knowing from where the actual data begins.
 Flags- There are six control flags or bits:
o URG: It indicates an urgent pointer. If URG is set, then the data is processed
urgently.
o ACK: It represents the acknowledgment field in a segment. If the ACK is set to 0,
the data packet does not contain an acknowledgment.
o RST: It Resets the connection. If RST is set, then it requests to restart a
connection.
o PSH: If this field is set, the receiving device is requested to push the data directly
to the receiving application without buffering it.
o SYN: It initiates and establishes a connection between the hosts. If SYN is set, the
device wants to establish a secure connection; else, not.
o FIN: It is used to terminate a connection. If FIN is 1, the device wants to
terminate the connection; else, not.
 Checksum- A checksum is a sequence of numbers and letters used to detect errors in
data. It is a 16-bit field that is optional in UDP but mandatory in TCP/IP.
 Window size- It is a 16-bit field. This field specifies the size of data that the receiver can
accept.
 Urgent pointer- This field (valid only If the URG flag is set to 1) is used to indicate
urgently needed data and must be received as soon as possible. It specifies a value that
will be appended to the sequence number to get the last urgent byte's sequence number.

TCP 3-way Handshake Process


TCP 3-way handshake process is used for establishing and terminating the connection between
the client and server.

Steps of a 3-Way Handshake for Establishing the Connection

The three steps involved in establishing a connection using the 3-way handshake process in TCP
are as follows:
Unit III Transport Layer

1. The client sends the SYN (synchronize) message to the server: When a client requests to
connect to a server, it sends the message to the server with the SYN flag set to 1. The
message also includes:
o The sequence number (any random 32-bit number).
o The ACK (which is set to 0 in this case).
o The window size.
o The maximum segment size. For example, if the window size is 3000 bits and the
maximum segment size is 300 bits, the connection can send a maximum of 10
data segments (3000/300 = 10).This MSS field come in Options & Padding in
Header Fromat of TCP.
2. The server responds with the SYN and the ACK (synchronize-acknowledge) message to
the client: After receiving the synchronization request, the server sends the client an
acknowledgment by changing the ACK flag to '1'. The ACK's acknowledgment number
is one higher than the sequence number received. If the client sends an SYN with a
sequence number of 2000, the server will send the ACK using acknowledgment number
= 20001. If the server wants to create the connection, it sets the SYN flag to '1' and
transmits it to the client. The SYN sequence number used here will be different from the
SYN used by the client. The server also informs the client of its window size and
maximum segment size. After this step is completed, the connection is established from
the client to the server.
3. The client sends the ACK (acknowledge) message to the server: The client will set the
ACK flag to '1' after receiving the SYN from the server and transmits it with an
acknowledgment number 1 greater than the server's SYN sequence number. The SYN
flag has been set to '0' in this case. The connection between the server and the client is
now formed after this phase is completed.

Refer to the diagram below that explains the connection establishment process using the 3-way
handshake.

Steps of a 3-Way Handshake for Terminating the Connection


Unit III Transport Layer

Most implementations today allow three-way and four-way handshaking with a half-close option
for connection termination. Here we only mentioned the steps of three-way handshaking for
connection termination. The three steps involved in terminating a connection using the 3-way
handshake process in TCP are as follows:

1. The client sends the FIN (finish) message to the server: When the client decides to
disconnect from the network, it transmits the message to the server with a random
sequence number and sets the FIN flag to '1'. ACK is set to 0 in this case.
2. The server responds with the FIN and the ACK (finish-acknowledge) message to the
client: After receiving the request, the server acknowledges the client's termination
request by changing the ACK flag to '1'. The ACK's acknowledgment number is one
higher than the sequence number received. If the client sends a FIN with a sequence
number of 2000, the server will send the ACK using acknowledgment number = 20001.
If the server also decides to terminate the connection, it sets the FIN flag to '1' and
transmits it to the client. The FIN sequence number used here will be different from the
FIN used by the client. After this step is completed, the connection between the client to
the server is disconnected.
3. The client sends the ACK (acknowledge) message to the server: The client will set the
ACK flag to '1' after receiving the FIN from the server and transmits it with an
acknowledgment number 1 greater than the server's FIN sequence number. The FIN flag
is set to '0' in this case. After this step is completed, the connection is also disconnected
from the server to the client.

Refer to the diagram below that explains the connection termination process using the 3-way
handshake.

Conclusion
 TCP 3-way handshake, also known as a 3-way handshake, is a protocol for establishing a
connection between a server and a client in a TCP/IP network.
 A client must initiate a conversation by using the TCP handshake to request a
communication session with the server.
Unit III Transport Layer

 SYN flag is used to start and maintain a connection while the ACK flag confirms that the
other side has received the SYN flag.
 The FIN flag is used to terminate a connection.
 The server replies to the client request with the SYN-ACK signal set in the second step.
 The client acknowledges the server's response in the final step.

Multiplexing & Demultiplexing

Multiplexing and Demultiplexing services are provided in almost every protocol architecture ever
designed. UDP and TCP perform the demultiplexing and multiplexing jobs by including two special fields
in the segment headers: the source port number field and the destination port number field.

Multiplexing –
Gathering data from multiple application processes of the sender, enveloping that data with a header,
and sending them as a whole to the intended receiver is called multiplexing.

Demultiplexing –
Delivering received segments at the receiver side to the correct app layer processes is called
demultiplexing.

Figure – Abstract view of multiplexing and demultiplexing

Multiplexing and demultiplexing are the services facilitated by the transport layer of the OSI
model.

There are two types of multiplexing and Demultiplexing :


Unit III Transport Layer

1. Connectionless Multiplexing and Demultiplexing


2. Connection-Oriented Multiplexing and Demultiplexing

How Multiplexing and Demultiplexing is done –


For sending data from an application on the sender side to an application at the destination side,
the sender must know the IP address of the destination and port number of the application (at the
destination side) to which he wants to transfer the data. Block diagram is shown below :

Figure – Transfer of packet between applications of sender and receiver

Let us consider two messaging apps that are widely used nowadays viz. Hike and WhatsApp.
Suppose A is the sender and B is the receiver. Both sender and receiver have these applications
installed in their system (say smartphone). Suppose A wants to send messages to B in WhatsApp
and hike both. In order to do so, A must mention the IP address of B and destination port number
of the WhatsApp while sending the message through the WhatsApp application. Similarly, for
the latter case, A must mention the IP address of B and the destination port number of the hike
while sending the message.

Now the messages from both the apps will be wrapped up along with appropriate headers(viz.
source IP address, destination IP address, source port no, destination port number) and sent as a
single message to the receiver. This process is called multiplexing. At the destination, the
received message is unwrapped and constituent messages (viz messages from a hike and
WhatsApp application) are sent to the appropriate application by looking to the destination the
port number. This process is called demultiplexing. Similarly, B can also transfer the messages
to A.

UDP Protocol

User Datagram Protocol (UDP) is a Transport Layer protocol. UDP is a part of the Internet
Protocol suite, referred to as UDP/IP suite. Unlike TCP, 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.
Unit III Transport Layer

Though Transmission Control Protocol (TCP) is the dominant transport layer protocol used with
most of the Internet services; provides assured delivery, reliability, and much more but all these
services cost us additional overhead and latency. Here, UDP comes into the picture. For real-
time services like computer gaming, voice or video communication, live conferences; we need
UDP. Since high performance is needed, UDP permits packets to be dropped instead of
processing delayed packets. There is no error checking in UDP, so it also saves bandwidth.
User Datagram Protocol (UDP) is more efficient in terms of both latency and bandwidth.

UDP Header –

UDP header is an 8-bytes fixed and simple header, while for TCP it may vary from 20 bytes to
60 bytes. The first 8 Bytes contains all necessary header information and the remaining part
consist of data. UDP port number fields are each 16 bits long, therefore the range for port
numbers is defined from 0 to 65535; port number 0 is reserved. Port numbers help to distinguish
different user requests or processes.

1. Source Port: Source Port is a 2 Byte long field used to identify the port number of the
source.
2. Destination Port: It is a 2 Byte long field, used to identify the port of the destined
packet.
3. Length: Length is the length of UDP including the header and the data. It is a 16-bits
field.
4. Checksum: Checksum is 2 Bytes long field. It is the 16-bit one’s complement of the
one’s complement sum of the UDP header, the pseudo-header of information from the IP
header, and the data, padded with zero octets at the end (if necessary) to make a multiple
of two octets.

Unlike TCP, the Checksum calculation is not mandatory in UDP. No Error control or flow
control is provided by UDP. Hence UDP depends on IP and ICMP for error reporting. Also UDP
provides port numbers so that is can differentiate between users requests.

Applications of UDP:

 Used for simple request-response communication when the size of data is less and hence
there is lesser concern about flow and error control.
Unit III Transport Layer

 It is a suitable protocol for multicasting as UDP supports packet switching.


 UDP is used for some routing update protocols like RIP(Routing Information Protocol).
 Normally used for real-time applications which can not tolerate uneven delays between
sections of a received message.
 Following implementations uses UDP as a transport layer protocol:
o NTP (Network Time Protocol)
o DNS (Domain Name Service)
o BOOTP, DHCP.
o NNP (Network News Protocol)
o Quote of the day protocol
o TFTP, RTSP, RIP.
 The application layer can do some of the tasks through UDP-
o Trace Route
o Record Route
o Timestamp
 UDP takes a datagram from Network Layer, attaches its header, and sends it to the user.
So, it works fast.
 Actually, UDP is a null protocol if you remove the checksum field.
1. Reduce the requirement of computer resources.
2. When using the Multicast or Broadcast to transfer.
3. The transmission of Real-time packets, mainly in multimedia applications.
Unit III Transport Layer
Unit III Transport Layer
Unit III Transport Layer
Unit III Transport Layer
Unit III Transport Layer

You might also like