MODULE 4
TRANSPORT LAYER
1. ELEMENTS OF TRANSPORT LAYER
2. ADDRESSING
3. CONNECTION ESTABLISHMENT AND CONNECTION
RELEASE
4. CRASH RECOVERY
5. UDP
6. TCP
7. TCP CONGESTION CONTROL
8. QOS
9. QOS: IMPROVING TECHINQUES(TOKEN BUCKET AND
LEAKY BUCKET)
Key responsibilities of the transport layer
End-to-end and process-to-process delivery: The transport layer ensures
data is delivered to the correct application
Segmentation and reassembly: It breaks down large chunks of data from
the application layer into smaller segments for transmission and reassembles
them into the original data at the receiving end.
Error control: It detects and handles errors in the data, often using
checksums
Flow control: It manages the rate of data transmission to prevent a fast
sender from overwhelming a slow receiver,
Multiplexing and demultiplexing: It allows multiple application processes to
share the same network connection simultaneously
Reliable vs. unreliable communication:
It offers different services based on the protocol used.
Reliable (TCP): Guarantees that all data arrives correctly and in order,
which is essential for applications like web browsing and file
downloads.
Unreliable (UDP): Prioritizes speed over guaranteed delivery, making
it suitable for applications like live video streaming and online gaming
where occasional data loss is acceptable.
1 ELEMENTS OF TRANSPORT LAYER
A)Error Control
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.
B)Flow Control
The underlying rule of flow control is to maintain a synergy between a fast
process and a slow process. The transport layer enables a fast process to keep
pace with a slow one. Acknowledgements are sent back to manage end-to-end
flow control. Go back N algorithms are used to request retransmission of
packets starting with packet number N. Selective Repeat is used to request
specific packets to be retransmitted.
C)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.
Connection establishment (TCP three-way handshake)
This process ensures both client and server are ready to communicate before data is
sent:
1. SYN:
The client sends a SYN (synchronize) segment to the server to initiate the
connection and proposes an initial sequence number.
2. SYN-ACK:
The server responds with a SYN-ACK segment. It acknowledges the
client's SYN (by setting the ACK flag and using the client's sequence number +
1) and sends its own SYN to propose its initial sequence number.
3. ACK:
The client sends an ACK segment to acknowledge the server's SYN-ACK,
completing the handshake. The connection is now established and data can
be exchanged.
IMPORTANCE OF CONNECTION ESTABLISHMENT::Synchronizes and
prepares both endpoints. It establishes initial parameters like sequence numbers,
buffer sizes, and ensures both sides are ready for data transfer
Connection release (TCP four-way handshake)
This process ensures both sides have finished sending data before the connection is
fully closed:
1. FIN:
One side (e.g., the client) sends a FIN segment to indicate it has no more data
to send.
2. ACK:
The other side (the server) responds with an ACK to acknowledge the FIN. The
connection is now closed in the client's direction, but data can still be sent
from the server to the client.
3. FIN:
When the server is also ready to close, it sends its own FIN segment to the
client.
4. ACK:
The client acknowledges the server's FIN, and the connection is now fully
terminated from both ends.
IMPORTANCE OF CONNECTION RELEASE::. Provides a clean and orderly
termination of communication. This prevents data loss and ensures that both
ends agree the connection is closed, preventing resource leaks and future
confusion.
D)Addressing
Transport Layer deals with addressing or labelling a frame. It also
differentiates between a connection and a transaction. Connection identifiers
are ports or sockets that label each frame, so the receiving device knows which
process it has been sent from. This helps in keeping track of multiple-message
conversations. Ports or sockets address multiple conservations in the same
location.
IMPORTANCE OF ADDRESSING
Ensures data reaches the correct application. Without port numbers, a host
might not know which process to deliver incoming data to, leading to
communication failure.
2::ADDRESSING
Addressing in a computer network is the process of assigning unique identifiers to devices so
they can communicate with each other. These identifiers, which operate at different layers of
the network model, include physical (MAC) addresses for local delivery, logical (IP)
addresses for routing across networks, and port addresses for specific applications. Correct
addressing ensures data is sent to the right destination by allowing devices to find routes and
establish communication.
Types of network addresses
Physical Address (MAC Address):
A unique identifier for the network interface card (NIC) of a device, used for
communication on a local network segment. The first 24 bits are the Organizationally
Unique Identifier (OUI) assigned to the manufacturer, and the last 24 bits are assigned
by the manufacturer to the specific device.
Logical Address (IP Address):
A network-level address used for routing packets across different networks. Routers
use the destination IP address to forward data to the correct network.
o IPv4: A 32-bit address typically written in dotted-decimal notation (e.g.,
192.168 .1.1).
o IPv6: A 128-bit address designed to replace IPv4 due to the exhaustion of
IPv4 addresses.
Port Address:
Used at the transport layer to identify a specific process or service on a host, allowing
data to be delivered to the correct application.
Application-Specific Address:
Used by applications to identify and locate network resources, such as a URL or a
domain name.
How addressing works
Communication:
Devices use these addresses to send and receive data. For example, when a computer
sends a message, its IP address is the source IP, and the IP address of the destination
computer is the destination IP.
Routing:
Routers examine the destination IP address to decide the best path to forward the
packet across networks.
Reply:
When the destination receives the message and replies, the source and destination IP
addresses are swapped in the new packet.
3 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.
Connection establishment (TCP three-way handshake)
This process ensures both client and server are ready to communicate before data is
sent: (3 STEPS IN HANDASHAKE)
1 SYN:
The client sends a SYN (synchronize) segment to the server to initiate the
connection and proposes an initial sequence number.
2 SYN-ACK:
The server responds with a SYN-ACK segment. It acknowledges the
client's SYN (by setting the ACK flag and using the client's sequence number +
1) and sends its own SYN to propose its initial sequence number.
3 ACK:
The client sends an ACK segment to acknowledge the server's SYN-ACK,
completing the handshake. The connection is now established and data can
be exchanged.
Connection release (TCP four-way handshake)
This process ensures both sides have finished sending data before the connection is
fully closed:
1 FIN:
One side (e.g., the client) sends a FIN segment to indicate it has no more data
to send.
2 ACK:
The other side (the server) responds with an ACK to acknowledge the FIN. The
connection is now closed in the client's direction, but data can still be sent
from the server to the client.
3 FIN:
When the server is also ready to close, it sends its own FIN segment to the
client.
4 ACK:
The client acknowledges the server's FIN, and the connection is now fully
terminated from both ends.
4::CRASH RECOVERY
Crash recovery is vital in transport protocols to ensure reliable data delivery
after unexpected disruptions like hardware or software failures. It works by
detecting and rectifying disruptions through mechanisms like
acknowledgements, retransmissions, and logging, which restore data integrity
and prevent data loss or duplication. Different protocols use different
mechanisms, such as TCP's sequence numbers and acknowledgements, or
more advanced techniques like write-ahead logging and checkpointing in
databases.
Importance of crash recovery
Ensures data integrity:
By detecting and correcting errors, crash recovery mechanisms ensure data is
not lost or corrupted during a crash.
Maintains reliability:
They allow for the resumption of communication, ensuring that data is
consistently and reliably delivered even after failures.
Handles different crash scenarios:
Recovery mechanisms are designed to handle various scenarios, such as a
server crashing before or after sending an acknowledgment, which can lead to
data loss or duplication.
Provides transparency to applications:
While crashes are not transparent to the upper layers, the transport layer
recovers the state and ensures the application continues from where it left
off.
Effectiveness of different crash recovery mechanisms
Mechanism Description Effectiveness
Acknowledgement When a sender transmits data, Effective: This is a
s and it expects an acknowledgement foundational method in
Retransmissions (ACK) from the receiver. If no protocols like TCP for handling
ACK is received within a packet loss and ensuring data
certain time, the sender reaches its destination. It is
assumes the data was lost and simple and effective for a wide
retransmits it. range of failures.
Sequence Numbers Sequence numbers allow the Effective: Crucial for
receiver to identify and discard preventing duplication after a
duplicate packets that might be retransmission, which is a
sent during a retransmission, common side effect of a crash
ensuring data is not duplicated. recovery process.
Logging and Used in more complex systems Highly Effective: This is a
Checkpointing like databases, this involves robust mechanism for high-
logging all changes to a reliability systems. It ensures
transaction log before they are that the system can be
committed to restored to a consistent state
disk. Checkpointing even if it crashes before all
periodically creates a transactions are complete. The
consistent state in the log. ARIES algorithm is a well-
regarded example.
Timeouts A timer is set when data is Effective: Essential for
sent. If the timer expires before detecting lost packets and
an acknowledgement is initiating recovery. The
received, the data is considered effectiveness depends on the
lost and retransmission is appropriate setting of the
initiated. timeout value to avoid
premature retransmissions or
excessive delays.
Connection When a server crashes, a client Effective: This allows the
Management might not know the server's server to re-establish its state
state. Some protocols use a after a crash by receiving
"broadcast" state status updates from clients,
announcement to all which is useful for quickly
connections to understand resuming operations.
what data was lost or what
data is still outstanding.
5 UDP
Connectionless protocol
Unreliable protocol
UDP stands for User Datagram Protocol.
UDP is one of the simplest transport layer protocols which provides
nonsequenced data transmission functionality.
UDP is considered as a connectionless transport layer protocol.
This type of protocol is referred to be used when speed and size are more
important than reliability and security.
It is an end-to-end transport-level protocol that adds transport-level
addresses, checksum error control, and length information to the data
received from the upper layer.
User datagram is the packet constructed by the UDP protocol
Format of User Datagram
Refer to the image below to see the header of the UDP packet consisting of four
fields.
User datagrams have a fixed-size header of 8 bytes which is divided into four parts
-
Source port address: It defines the source port number and it is 16 bits.
Destination port address: It defines the destination port number and it is 16 bits.
Total length: This field is used to define the total length of the user datagram
which is the sum of header and data length in bytes. It is a 16-bit field.
Checksum: Checksum is also a 16-bit field to carry the optional error detection
data.
UDP Services
Process to Process Communication
Connectionless Service
Fast delivery of the message
Checksum
Key advantages of UDP
Speed and Low Latency
Efficiency and Low Overhead
Broadcast and Multicast Support
Optional Error Checking
Reduced Impact from Congestion
Disadvantages
UDP delivers basic functions required for the end-to-end transmission of
data.
It does not use any sequencing and does not identify the damaged packet
while reporting an error.
UDP can identify that an error has happened, but UDP does not identify
which packet has been lost.
6 TCP
Connection-oriented protocol
Reliable protocol
Provide error and flow control
TCP stands for Transmission Control Protocol.
TCP is a connection-oriented transport layer protocol.
TCP explicitly defines connection establishment, data transfer, and
connection tear-down phases to provide connection-oriented service for data
transmission.
TCP is the most commonly used transport layer protocol.
Features of TCP Protocol
Stream data transfer
Reliability
Flow Control
Error Control
Multiplexing
Logical Connections
Full Duplex
TCP Segment Format
Refer to the image below to see the header of TCP Segment.
Source port address is a 16-bit field that defines the port number of an
application program that is sending the segment.
Destination port address is a 16-bit field that defines the port number of an
application program that is receiving the segment.
Sequence number is a field of 32 bits that will define the number assigned
to data's first byte contained in the segment.
Acknowledgement number is a 32-bit field that describes the next byte that
the receiver is looking forward to receiving from sender.
Header Length (HLEN) is a field of 4 bit that specify the number of 4-byte
words in TCP header. The header length of TCP header can be between 20
to 60 bytes.
Reserved is a field 6 bit that is reserved for future use.
Control bits are 6 different independent control bits or flags in this field.
There are six in the control field:
1. URG: Urgent pointer
2. ACK: Acknowledgement number
3. PSH: Push request
4. RST: Reset connection
5. SYN: Sequence number Synchronization
6. FIN: Connection termination
Window Size is a 16-bit field that defines the size of the window of sending
TCP in bytes.
Checksum, 16-bit field contains checksum and is used for error detection.
Urgent pointer is a 16 bit field. This flag is set when there is urgent data in
the data segment.
Options and padding can be up to 40 bytes field for optional information in
TCP header.
Advantages
Reliable data delivery.
Error recovery
Congestion control:
Flow control:
Connection-oriented:
Broad compatibility:
Disadvantages
Higher latency
Not ideal for time-sensitive data
Slower initial transfer
Reduced throughput in congestion
Less efficient for simple transfers
Feature TCP (Transmission Control Protocol) UDP (User Datagram Protocol)
Connection Connection-oriented; uses a three-way Connectionless; sends data without
Type handshake to establish a connection before establishing a connection first
data transfer
Reliability Reliable; guarantees data delivery Unreliable; does not guarantee data
delivery
Data Yes; data packets are sequenced and No; data packets can arrive out of order
Sequencing reassembled in the correct order
Error Control Yes; includes error checking and Basic error checking (checksum) but no
recovery, retransmits lost packets recovery; erroneous packets are
discarded
Flow Control Yes; prevents overwhelming the receiver No
Speed Slower due to overhead from reliability Faster due to less overhead
features
Header Size 20-60 bytes 8 bytes
Transmission Byte stream Message stream/packets
Broadcast No Yes
Examples HTTP, HTTPS, FTP, SMTP, Telnet DNS, DHCP, TFTP, VoIP, streaming
video
Suitability of TCP in applications/REAL WORLD SCENARIO OF TCP
.
Application Justification
Web Browsing When you load a website, all the components—HTML, CSS, images, and
(HTTP/HTTPS) scripts—must arrive completely and in the correct order to render the
page correctly. TCP ensures that if a packet is dropped, it is retransmitted
until the entire web page loads perfectly.
Email (SMTP, Email transmissions cannot afford to lose any data. TCP guarantees that
IMAP, POP3) every part of the message and its attachments are transferred without
error, ensuring the email is delivered to the recipient intact.
File Transfer (FTP, File integrity is critical. When downloading a file, you need every single
SFTP) byte to arrive perfectly. TCP handles this by numbering and
acknowledging each packet, retransmitting any lost ones to prevent file
corruption.
Suitability of UDP in applications/ REAL WORLD SCENARIO OF UDP
Application Justification
Online Responsiveness is key in real-time games. Using UDP reduces latency because
Gaming the game client doesn't wait for acknowledgments or retransmissions of lost
packets. A small amount of data loss is often unnoticeable and preferable to
game lag.
Voice over IP In a voice or video call, a steady stream of data is more important than perfect
(VoIP) delivery. UDP ensures low latency for real-time communication. If a few
packets containing voice data are lost, a small glitch occurs, which is better than
the noticeable pause that TCP's retransmission would cause.
FLOW CONTROL PROTOCOL Flow control is the process of
regulating data transmission speed between a sender and a receiver to prevent the sender from
overwhelming the receiver.
Concept of flow control
Mechanism:
Flow control is managed by the transport layer to regulate the flow of data
between two end-hosts.
Purpose:
It prevents a sender from overwhelming a receiver with data faster than it can
be processed, stored, or consumed.
How it works:
The receiver sends feedback to the sender, indicating how much data it can
currently receive. The sender then adjusts its transmission rate to match this
feedback.
Key difference:
Flow control is distinct from congestion control, which manages data to
prevent overwhelming the network itself, whereas flow control is about
preventing the receiver from being overwhelmed.
Flow control in a real-world scenario
Scenario: Streaming a video on a mobile device
1. Sender: The video streaming server on the internet.
2. Receiver: Your mobile device's app.
3. Process:
o The app on your phone requests a video stream from the server.
o The server begins sending video data packets, but your phone's
memory (buffer) can only hold a limited amount of data.
o Your phone's operating system, via the TCP protocol, advertises a
"receive window size" to the server. This window size tells the
server the maximum amount of unacknowledged data the phone
can currently accept.
o The server sends data up to the limit of the window size. When
the phone processes some data, it sends an acknowledgment
(ACK) back, which shrinks the used portion of the window and
allows the server to send more data.
o If your phone is busy, or the Wi-Fi connection is slow, the receive
window will be smaller, and the server will automatically send
data more slowly.
o If the phone is struggling to keep up, it will send an ACK for only a
small amount of data, causing the server to slow down and
preventing the video stream from stalling or dropping packets
due to buffer overflow.
o
[Link] CONGESTION CONTROL
1. Slow Start Phase
TCP increases its congestion window exponentially to quickly probe the
network capacity at the beginning of a connection.
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
2. Congestion Avoidance Phase
TCP increases its congestion window linearly to prevent network congestion
after the slow start.
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.
For 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
will 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
ANALYZE THE IMPACT OF CONGESTION CONTROL
POSITIVE IMPACT
Reduced latency and packet loss
Enhanced throughput
Fairness
Improved user experience
Stability and scalability
NEGATIVE IMPACT
Over-correction on wireless networks
Increased complexity
8 QOS
9::::QOS: IMPROVING TECHINQUES(TOKEN BUCKET AND
LEAKY BUCKET)
Congestion control refers to techniques and mechanisms in computer
networks that prevent or manage congestion, which occurs when too much
data is sent, causing delays and packet loss
TWO TYPES OF ALGORITHM
LEAKY BUCKET ALGORITHM
TOKEN BUCKET ALGORITHM
LEAKY BUCKET ALGORITHM
The leaky bucket algorithm is a network traffic shaping method that smooths
out bursty traffic by sending packets out at a constant rate, similar to how a
leaky bucket drips water at a steady pace. It uses a fixed-size buffer (the
bucket) to store incoming packets. If the buffer is not full, packets are added; if
the bucket's leak rate is slower than the arrival rate, the excess packets are
either discarded or delayed when the bucket overflows
How it works
Input:
Bursty data packets arrive at the network interface at varying rates.
Buffer:
These packets are placed into a buffer (the "bucket"), which has a finite size.
Output:
The algorithm releases packets from the buffer at a constant, steady rate,
regardless of the input rate.
Overflow:
If packets arrive faster than the bucket can leak them, the bucket fills up. Any
packets that would cause the bucket to overflow are discarded.
Advantages:
Traffic smoothing: Provides a constant output rate, which is
useful for preventing network congestion and ensuring a steady
flow.
Simplicity: Easier to implement and manage than the Token
Bucket algorithm.
Efficiency: Can provide efficient bandwidth use by sending data
at a steady rate and preventing large bursts.
Disadvantages:
Inefficient with bursts: Cannot handle bursty traffic efficiently
because it enforces a constant output rate, which can lead to
packet loss if the incoming rate is too high for a prolonged
period.
Lack of flexibility: Lacks flexibility and cannot handle prioritized
or urgent requests effectively.
Increased delay: Can cause a delay for requests that arrive after
a long idle period, as the "leak" only starts processing at the
beginning of the next interval.
The token bucket algorithm is a method used in networking to
control network traffic by allowing for bursts of data while ensuring an
average transmission rate is not exceeded. It works by filling a "bucket" with
"tokens" at a fixed rate; each token represents permission to send a certain
amount of data. To send data, tokens are removed from the bucket. If the
bucket is full, it stops accepting tokens; if the bucket is empty, data
transmission must wait until more tokens are added
Advantages:
Handles bursts: Allows for bursts of data to be transmitted at a higher rate
than the average rate by accumulating tokens during periods of low activity.
Flexibility: Provides more flexibility and control over traffic shaping by
adjusting the token arrival rate and maximum token count.
Efficiency: Tokens are discarded, not packets, when the bucket is full, which
avoids packet loss for valid bursts.
Disadvantages:
Complexity: Can be more complex to implement due to the added token
management.
Token wastage: Tokens can be discarded if they are not used, which may be
considered an inefficient use of network resources if the bursts are
unpredictable.
Potential for delay: Can cause a delay if the token bucket becomes empty,
forcing new packets to wait for tokens to accumulate.
*****ALL THE BEST****