CN Unit-4
CN Unit-4
The Transport layer is the layer-4 of the OSI reference model. The transport layer
is mainly responsible for the process-to-process delivery of the entire message. A
process is basically an application program that is running on the host. The basic
function of the Transport layer is to accept data from the upper layer and split it up
into smaller units, pass these data units to the Network layer, and ensure that all
the pieces arrive correctly at the other end.
Network layer is responsible for the end to end delivery of individual packets from
a machine to another machine in different network, but does not see any
relationship between those packets. It treats each as an independent entity. Further,
the packet needs to be delivered to the last participating entity, i.e. a process
engaged in data exchanged. But the transport layer makes sure that the entire
message (not a single packets receives) is delivered to a process. So it provides
process-to-process or end-to-end delivery of an entire message.
The Transport layer also determines what type of service to provide to the Session
layer, and, ultimately, to the users of the network.
The transport layer also identifies errors like damaged packets, lost packets, and
duplication of packets, and provides sufficient techniques for error correction.
This layer mainly provides the transparent transfer of data between end-users, also
provides the reliable transfer of data to the upper layers.
1. Service Point Addressing: Transport Layer header includes service point address
which is the port address. This layer gets the message to the correct process on
the computer unlike Network Layer, which gets each packet to the correct
computer.
UDP
o UDP stands for User Datagram Protocol.
o UDP is a simple protocol and it provides non sequenced transport functionality.
o UDP is a connectionless protocol.
o This type of protocol is used when reliability and security are less important than
speed and size.
o UDP is an end-to-end transport level protocol that adds transport-level addresses,
checksum error control, and length information to the data from the upper layer.
o The packet produced by the UDP protocol is known as a user datagram.
Where,
o Source port address: It defines the address of the application process that has
delivered a message. The source port address is of 16 bits address.
o Destination port address: It defines the address of the application process that
will receive the message. The destination port address is of a 16-bit address.
o Total length: It defines the total length of the user datagram in bytes. It is a 16-bit
field.
o Checksum: The checksum is a 16-bit field which is used in error detection.
TCP
o TCP stands for Transmission Control Protocol.
o It provides full transport layer services to applications.
o It is a connection-oriented protocol means the connection established between
both the ends of the transmission. For creating the connection, TCP generates a
virtual circuit between sender and receiver for the duration of a transmission.
o Stream data transfer: TCP protocol transfers the data in the form of contiguous
stream of bytes. TCP group the bytes in the form of TCP segments and then
passed it to the IP layer for transmission to the destination. TCP itself segments
the data and forward to the IP.
o Reliability: TCP assigns a sequence number to each byte transmitted and expects
a positive acknowledgement from the receiving TCP. If ACK is not received within a
timeout interval, then the data is retransmitted to the destination.
The receiving TCP uses the sequence number to reassemble the segments if they
arrive out of order or to eliminate the duplicate segments.
o Flow Control: When receiving TCP sends an acknowledgement back to the sender
indicating the number the bytes it can receive without overflowing its internal
buffer. The number of bytes is sent in ACK in the form of the highest sequence
number that it can receive without any problem. This mechanism is also referred
to as a window mechanism.
o Multiplexing: Multiplexing is a process of accepting the data from different
applications and forwarding to the different applications on different computers.
At the receiving end, the data is forwarded to the correct application. This process
is known as demultiplexing. TCP transmits the packet to the correct application by
using the logical channels known as ports.
o Logical Connections: The combination of sockets, sequence numbers, and
window sizes, is called a logical connection. Each connection is identified by the
pair of sockets used by sending and receiving processes.
o Full Duplex: TCP provides Full Duplex service, i.e., the data flow in both the
directions at the same time. To achieve Full Duplex service, each TCP should have
sending and receiving buffers so that the segments can flow in both the directions.
TCP is a connection-oriented protocol. Suppose the process A wants to send and
receive the data from process B. The following steps occur:
o Establish a connection between two TCPs.
o Data is exchanged in both the directions.
o The Connection is terminated.
o Window size
It is a 16-bit field. It contains the size of data that the receiver can accept. This field
is used for the flow control between the sender and receiver and also determines
the amount of buffer allocated by the receiver for a segment. The value of this
field is determined by the receiver.
o Checksum
It is a 16-bit field. This field is optional in UDP, but in the case of TCP/IP, this field
is mandatory.
o Urgent pointer
It is a pointer that points to the urgent data byte if the URG flag is set to 1. It
defines a value that will be added to the sequence number to get the sequence
number of the last urgent byte.
o Options
It provides additional options. The optional field is represented in 32-bits. If this
field contains the data less than 32-bit, then padding is required to obtain the
remaining bits.
Advantages of TCP
o It provides a connection-oriented reliable service, which means that it
guarantees the delivery of data packets. If the data packet is lost across the
network, then the TCP will resend the lost packets.
o It provides a flow control mechanism using a sliding window protocol.
o It provides error detection by using checksum and error control by using Go
Back or ARP protocol.
o It eliminates the congestion by using a network congestion avoidance
algorithm that includes various schemes such as additive
increase/multiplicative decrease (AIMD), slow start, and congestion window.
Disadvantage of TCP
It increases a large amount of overhead as each segment gets its own TCP
header, so fragmentation by the router increases the overhead.
TCP serves as an intermediary between two applications that need to exchange data.
When an application wants to transmit data, TCP ensures that:
1. Connection establishment.
2. Data transfer.
3. Connection termination.
1. Connection establishment.
The client sends the segment with its sequence number with SYN Primitive.
The server, in return, sends its segment with its own sequence number as well
as the acknowledgement sequence, which is one more than the client
sequence number.
When the client receives the acknowledgment of its segment, then it sends the
acknowledgment to the server. In this way, the connection is established
between the client and the server.
TCP Connection Establishment
To make the transport services reliable, TCP hosts must establish a connection-
oriented session with one another.
Connection establishment is performed by using the three-way handshake
mechanism. A three-way handshake synchronizes both ends of a network by
enabling both sides to agree upon original sequence numbers. This mechanism
also provides that both sides are ready to transmit data and learn that the other
side is available to communicate.
This is essential so that packets are not shared or retransmitted during session
establishment or after session termination. Each host randomly selects a sequence
number used to track bytes within the stream it is sending and receiving.
The three-way handshake proceeds in the manner shown in the figure below
The requesting end (Host A) sends an SYN segment determining the server's port
number that the client needs to connect to and its initial sequence number (x).
The server (Host B) acknowledges its own SYN segment, including the servers
initial sequence number (y). The server also responds to the client SYN by
accepting the sender's SYN plus one (X + 1).
An SYN consumes one sequence number. The client should acknowledge this
SYN from the server by accepting the server's SEQ plus one (SEQ = x + 1, ACK
= y + 1). This is how a TCP connection is settled.
Both are collectively called socket addresses. A port is the TCP name for TSAP
(Transport Service Access Point). It is essential to create a link between the
sockets of the sender & receiver.
Connections are used as identifiers at both ends. It can use the same socket for
greater than one connection at a time.
We explain some of the sockets call with their respectful meaning in the
following table. It also should know that TCP does not support multicasting &
broadcasting.
Different Socket Calls and their use at TCP service model are
The message boundaries are not maintained end to end. When an application
reaches information to TCP, and an application needs that data to be shared directly,
it sets the PUSH Flag, forcing the TCP to send information without any
interruption.
But when TCP doesn't send the data received from the above application
layer, it is collected for some time before sending. That is called Buffering.
Error Control in TCP
TCP is a reliable transport layer protocol. This means with the help of TCP an
application program delivers a stream of data to the application program on the
other end in order, without error, and without any part lost (Damage) or duplicated.
TCP provides reliability using error control.
Error control includes mechanisms for
Error control also includes a mechanism for correcting errors after they are
detected. Error detection and correction in TCP is achieved through the use of three
simple tools:
1. Checksum,
2. Acknowledgment,
3. Time-out.
In this scenario, the packet is received on the other side, but the acknowledgment is
lost, i.e., the ACK is not received on the sender side. Once the timeout period
expires, the packet is resent.
Scenario 3: When the Time out occurs.
In this scenario, the packet is sent, but due to the delay in acknowledgment or
timeout has occurred before the actual timeout, and then the packet is retransmitted
B. Retransmission after Three duplicate ACK segments: RTO method
works well when the value of RTO is small. If it is large, more time is
needed to get confirmation about whether a segment has been delivered or
not. Sometimes one segment is lost and the receiver receives so many out-
of-order segments that they cannot be saved. In order to solve this situation,
three duplicate acknowledgement methods are used. In this and missing
segment is retransmitted immediately instead of retransmitting already
delivered segment.
TCP Flow Control is a protocol designed to manage the data flow between the user
and the server. It ensures that there is a specific bandwidth for sending and receiving
data so the data can be processed without facing any major issues. In order to achieve
this, the TCP protocol uses a mechanism called the sliding window protocol
For the slow sender and fast receiver, no flow control is required. Whereas
for the fast sender and slow receiver, flow control is important
The above diagram shows a slow receiver and a fast sender. Let’s understand how
the messages will be overflown after a certain period.
The sender is sending messages at the rate of 10 messages per second, while
the receiver is receiving at the rate of 5 messages per second.
When a sender sends a message, the network enqueues messages in the
receiver queue.
Once the user application reads a message, the message is clear from the line,
and one buffer space adds to the free space.
Finally, after specific amount of time , there will be no space remaining for
incoming messages, and messages will start dropping.
To overcome this
With the flow control, the TCP receiver keeps sending the available space
capacity for the incoming messages to the sender during the communication.
The sender updates the space information and reduces the outgoing message
rate. The space is known as the receiver window size. For implementing flow
control, the sender should know how much free space is available on the
receiver before sending further messages.
For this both ends add their own window size in the header in each TCP
segment. During connection setup, the window size is the maximum capacity
available. During packet transfer, the window size keeps updating. The
window size value is zero when a TCP end cannot accept further messages.
When the sender receives a window size of zero, it stops sending any further
messages till it gets again a message with a window size of more than zero.
TCP Congestion -
Congestion refers to the state of a network where the message traffic becomes so
heavy that the network response time slows down leading to the failure of the
packet. It leads to packet loss. Due to this, it is necessary to control the congestion
in the network; however, it cannot be avoided.
TCP congestion control refers to the mechanism that prevents congestion from
happening or removes it after congestion takes place. When congestion takes place
in the network, TCP handles it by reducing the size of the sender’s window.
The window size of the sender is determined by the following two factors:
Receiver Window Size : It shows how much data a receiver can receive in bytes
without giving any acknowledgment.
The sender should not send data greater than that of the size of receiver
window. Hence sender should always send data that is less than or equal to
the size of the receiver’s window.
TCP header is used for sending the window size of the receiver to the sender.
Congestion Window
It is the state of TCP that limits the amount of data to be sent by the sender into the
network even before receiving the acknowledgment.
To calculate the size of the congestion window, different variants of TCP and
methods are used.
Only the sender knows the congestion window and its size and it is not sent
over the link or network.
The sender's window size is determined not only by the receiver but also by
congestion in the network.. The actual size of the sender window is the
minimum of the Receiver Window size and Congestion window size.
In the slow start phase, the sender sets congestion window size = maximum
segment size (1 MSS) at the initial stage.
The sender increases the size of the congestion window by 1 MSS after
receiving the ACK (acknowledgment).
The size of the congestion window increases exponentially in this phase.
(Initially its value is 1, 2nd time =2, 3rd time =4 and so on like this)
Congestion window size = Congestion window size + Maximum segment
size
This phase continues until the congestion window size reaches the slow start
threshold.Threshold = Maximum number of TCP segments that receiver
window can accommodate / 2
In this phase, the sender identifies the segment loss and gives acknowledgment
depending on the type of loss detected.
In this, the timer time-out expires even before receiving acknowledgment for a
segment. It suggests a stronger possibility of congestion in a network
Setting the threshold to start at half of the current size of the window
Slow start phase is resumed
This case suggests the weaker possibility of congestion in the network. In this, the
sender receives three duplicate acknowledgments for a network segment.
Setting the threshold to start at half of the current size of the window
Decreasing the size of the congestion window to that of the slow start
threshold.
The congestion avoidance phase is resumed
Congestion Control and Bandwidth Allocation:
BACP has several key functions that it performs in order to control the allocation of
bandwidth in ATM networks
Bandwidth negotiation − When a virtual channel is established between two
endpoints, BACP is used to negotiate the amount of bandwidth that will be
allocated to that channel.
Monitoring and adjustment − BACP monitors the usage of each virtual
channel and adjusts the allocated bandwidth as necessary to ensure fair
allocation among all channels. This dynamic adjustment of bandwidth helps
to optimize network performance and prevents congestion.
Congestion control − BACP provides mechanisms for handling network
congestion by reducing the amount of bandwidth allocated to certain virtual
channels or temporarily blocking new virtual channel requests. This ensures
that existing channels continue to receive the guaranteed minimum level of
service even when the network is congested.
Quality of Service (QoS) support − BACP supports different levels of QoS
for different types of traffic. It allows to provide different levels of service for
different types of traffic, such as real-time video or audio, and ensures that
these types of traffic receive the necessary bandwidth to maintain high-
quality service.
Support of different allocation techniques − BACP can use both
reservation-based and explicit rate-based methods to allocate bandwidth.
Reservation based allocation assign a fixed amount of bandwidth that is
guaranteed to the user, while explicit rate-based allocation assigns a
maximum amount of bandwidth, but is not guaranteed to have access to that
much bandwidth at all times.
Real Time Transport Protocol:
There are various features of the RTP protocol. Some main features of the RTP
protocol are as follows:
1. RTP support various types of file format, such as MPEG and MJPEG etc.
2. It runs in end systems. Jitter correction, detection of out-of-sequence arrival,
and multimedia streaming are also included in RTP data characteristics.
RTP's header format is very simple and supports all real-time applications. RTP
headers are made up of 32-bit with the following fields.
1. Version field: It defines the protocol version.
2. Padded bits: The P bit specifies the padded bit that is utilized for the packet in
multiples of 4 bytes.
3. Extension header: The length of this field is also 1 bit. If the value of this field is
1, it indicates that there is an extra extension header between the data and basic
headers, and if the value is 0, there is no extra extension.
RTP Header Format
Characteristics of SCTP:
STCP Packet consist of two main parts as Header and Payload. The Header is
common but the Payload consist of variable Chunks. These chunks are used for
various purposes.
Common STCP Header is 12 bytes long and it consists of the below parts:
Source Port Number :
Destination Port Number :
Verification Tag : is a 32-bit random value which distinguish the packets form
the previous connection.
Checksum
STCP Payload part consist of different STCP Chunks. These chunks have some
common parts. These are:
Type shows Control or Data Chunk. Type is 1 byte long.
Flags includes various chunk specific bits. Flag part is 1 byte long. There are 8 flag
bits.
Length shows size of chunk including chunk header. It is 2 bytes long.
Chunk Value includes chunk specific data.