CN (Unit Iv)
CN (Unit Iv)
CN (Unit Iv)
Transport Layer
The transport Layer is the second layer in the TCP/IP model and the
fourth layer in the OSI model.
It is an end-to-end layer used to deliver messages to a host.
It is termed an end-to-end layer because it provides a point-to-point
connection rather than hop-to-hop, between the source host and
destination host to deliver the services reliably.
The unit of data encapsulation in the Transport Layer is a segment.
The transport layer takes services from the Application layer and provides
services to the Network layer.
At the sender’s side: The transport layer receives data (message) from the
Application layer and then performs Segmentation, divides the actual message
into segments, adds the source and destination’s port numbers into the header
of the segment, and transfers the message to the Network layer.
At the receiver’s side: The transport layer receives data from the Network
layer, reassembles the segmented data, reads its header, identifies the port
number, and forwards the message to the appropriate port in the Application
layer.
o End-to-end delivery
o Addressing
o Reliable delivery
o Flow control
o Multiplexing
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.
o Error control
o Sequence control
o Loss control
o Duplication control
Error Control
o The primary role of reliability is Error Control. In reality, no transmission will be 100
percent error-free delivery. Therefore, transport layer protocols are designed to
provide error-free transmission.
o The data link layer also provides the error handling mechanism, but it ensures only
node-to-node error-free delivery. However, node-to-node reliability does not ensure
the end-to-end reliability.
o The data link layer checks for the error between each network. If an error is introduced
inside one of the routers, then this error will not be caught by the data link layer. It only
detects those errors that have been introduced between the beginning and end of the
link. Therefore, the transport layer performs the checking for the errors end-to-end to
ensure that the packet has arrived correctly.
Sequence Control
o The second aspect of the reliability is sequence control which is implemented at the
transport layer.
o On the sending end, the transport layer is responsible for ensuring that the packets
received from the upper layers can be used by the lower layers. On the receiving end,
it ensures that the various segments of a transmission can be correctly reassembled.
Loss Control
Loss Control is a third aspect of reliability. The transport layer ensures that all the
fragments of a transmission arrive at the destination, not some of them. On the
sending end, all the fragments of transmission are given sequence numbers by a
transport layer. These sequence numbers allow the receivers transport layer to identify
the missing segment.
Duplication Control
Duplication Control is the fourth aspect of reliability. The transport layer guarantees
that no duplicate data arrive at the destination. Sequence numbers are used to identify
the lost packets; similarly, it allows the receiver to identify and discard duplicate
segments.
Flow Control
Flow control is used to prevent the sender from overwhelming the receiver. If the
receiver is overloaded with too much data, then the receiver discards the packets and
asking for the retransmission of packets. This increases network congestion and thus,
reducing the system performance. The transport layer is responsible for flow control.
It uses the sliding window protocol that makes the data transmission more efficient as
well as it controls the flow of data so that the receiver does not become overwhelmed.
Sliding window protocol is byte oriented rather than frame oriented.
Multiplexing
The transport layer uses the multiplexing to improve transmission efficiency.
Addressing
o According to the layered model, the transport layer interacts with the functions of the
session layer. Many protocols combine session, presentation, and application layer
protocols into a single layer known as the application layer. In these cases, delivery to
the session layer means the delivery to the application layer. Data generated by an
application on one machine must be transmitted to the correct application on another
machine. In this case, addressing is provided by the transport layer.
o The transport layer provides the user address which is specified as a station or port.
The port variable represents a particular TS user of a specified station known as a
Transport Service access point (TSAP). Each station has only one transport entity.
o The transport layer protocols need to know which upper-layer protocols are
communicating.
Error detection and error recovery are an integral part of reliable service, and
therefore they are necessary to perform error control mechanisms on an end-to-
end basis. To control errors from lost or duplicate segments, the transport layer
enables unique segment sequence numbers to the different packets of the
message, creating virtual circuits, allowing only one virtual circuit per session.
Flow Control
Connection Establishment/Release
The transport layer creates and releases the connection across the network. This
includes a naming mechanism so that a process on one machine can indicate with
whom it wishes to communicate. The transport layer enables us to establish and
delete connections across the network to multiplex several message streams onto
one communication channel.
Multiplexing/De multiplexing
The transport layer establishes a separate network connection for each transport
connection required by the session layer. To improve throughput, the transport
layer establishes multiple network connections. When the issue of throughput is
not important, it multiplexes several transport connections onto the same network
connection, thus reducing the cost of establishing and maintaining the network
connections.
When several connections are multiplexed, they call for demultiplexing at the
receiving end. In the case of the transport layer, the communication takes place
only between two processes and not between two machines. Hence,
communication at the transport layer is also known as peer-to-peer or process-to-
process communication.
When the transport layer receives a large message from the session layer, it breaks
the message into smaller units depending upon the requirement. This process is
called fragmentation. Thereafter, it is passed to the network layer. Conversely,
when the transport layer acts as the receiving process, it reorders the pieces of a
message before reassembling them into a message.
Addressing
Congestion Control
TCP congestion control is a method used by the TCP protocol to manage
data flow over a network and prevent congestion. TCP uses a congestion
window and congestion policy that avoids congestion. Previously, we
assumed that only the receiver could dictate the sender’s window size. We
ignored another entity here, the network. If the network cannot deliver the
data as fast as it is created by the sender, it must tell the sender to slow
down. In other words, in addition to the receiver, the network is a second
entity that determines the size of the sender’s window
Congestion Policy in TCP
1. Slow Start Phase: Starts slow increment is exponential to the threshold.
2. Congestion Avoidance Phase: After reaching the threshold increment is
by 1.
3. Congestion Detection Phase: The sender goes back to the Slow start
phase or the Congestion avoidance phase.
Exponential increment: In this phase after every RTT the congestion window
size increments exponentially.
Example:- If the initial congestion window size is 1 segment, and the first
segment is successfully acknowledged, the congestion window size becomes
2 segments. If the next transmission is also acknowledged, the congestion
window size doubles to 4 segments. This exponential growth continues as long
as all segments are successfully acknowledged.
Initially cwnd = 1
After 1 RTT, cwnd = 2^(1) = 2
2 RTT, cwnd = 2^(2) = 4
3 RTT, cwnd = 2^(3) = 8
Additive increment: This phase starts after the threshold value also denoted
as ssthresh. The size of cwnd(congestion window) increases additive. After
each RTT cwnd = cwnd + 1.
Example:- if the congestion window size is 20 segments and all 20 segments
are successfully acknowledged within an RTT, the congestion window size
would be increased to 21 segments in the next RTT. If all 21 segments are
again successfully acknowledged, the congestion window size would be
increased to 22 segments, and so on.
Initially cwnd = i
After 1 RTT, cwnd = i+1
2 RTT, cwnd = i+2
3 RTT, cwnd = i+3
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.
Advantages of UDP
UDP also provides multicast and broadcast transmission of data.
UDP protocol is preferred more for small transactions such as DNS
lookup.
It is a connectionless protocol, therefore there is no compulsion to have a
connection-oriented network.
UDP provides fast delivery of messages.
Disadvantages of UDP
In UDP protocol there is no guarantee that the packet is delivered.
UDP protocol suffers from worse packet loss.
UDP protocol has no congestion control mechanism.
UDP protocol does not provide the sequential transmission of data.
2. 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 Source port address: It is used to define the address of the application program in a
source computer. It is a 16-bit field.
o Destination port address: It is used to define the address of the application program
in a destination computer. It is a 16-bit field.
o Sequence number: A stream of data is divided into two or more TCP segments. The
32-bit sequence number field represents the position of the data in an original data
stream.
o Acknowledgement number: A 32-field acknowledgement number acknowledge the
data from other communicating devices. If ACK field is set to 1, then it specifies the
sequence number that the receiver is expecting to receive.
o Header Length (HLEN): It specifies the size of the TCP header in 32-bit words. The
minimum size of the header is 5 words, and the maximum size of the header is 15
words. Therefore, the maximum size of the TCP header is 60 bytes, and the minimum
size of the TCP header is 20 bytes.
o Reserved: It is a six-bit field which is reserved for future use.
o Control bits: Each bit of a control field functions individually and independently. A
control bit defines the use of a segment or serves as a validity check for other fields.
Advantages of TCP
TCP supports multiple routing protocols.
TCP protocol operates independently of that of the operating system.
TCP protocol provides the features of error control and flow control.
TCP provides a connection-oriented protocol and provides the delivery of
data.
Disadvantages of TCP
TCP protocol cannot be used for broadcast or multicast transmission.
TCP protocol has no block boundaries.
No clear separation is being offered by TCP protocol between its
interface, services, and protocols.
In TCP/IP replacement of protocol is difficult.
Differences b/w TCP & UDP
Basis for TCP UDP
Comparison
Definition TCP establishes a virtual circuit UDP transmits the data directly to the
before transmitting the data. destination computer without
verifying whether the receiver is ready
to receive or not.
Congestion − When too many devices are trying to use the network at the
same time, congestion can occur, leading to slow performance.