Introduction to Transport Layer Protocols
Introduction to Transport Layer Protocols
Protocols
The transport layer in the TCP/IP protocol suite includes UDP, TCP, and SCTP. These protocols
provide different types of communication services.
Services Provided by Transport Layer ProtocolsUDP (User Datagram Protocol)Unreliable and
connectionless transport-layer protocol.
Used for simplicity and efficiency in applications where error control is handled at the application
layer.
TCP (Transmission Control Protocol)Reliable and connection-oriented protocol. Used in
applications where data integrity and reliability are crucial.
SCTP (Stream Control Transmission Protocol)Newer protocol that combines features of both UDP
and TCP.
Supports multi-streaming and multi-homing for improved reliability.Port NumbersPort numbers are
used to establish process-to-process communication.
They provide end-to-end addressing at the transport layer, similar to how IP addresses work at
the network layer.Port numbers enable multiplexing and demultiplexing of data.
User Datagram Protocol
Process-to-process communication
Reliable data transfer
Error detection & correction
Flow control
Congestion control
Port Numbers & Process
Communication
TCP does not send raw streams of bytes over the network; it groups
bytes into segments .
Each segment contains a header (for control information) and a data
payload
Segments are then encapsulated into IP datagrams and transmitted.
Reliable Delivery
Segments are not of fixed size; they can vary based on the network
conditions and buffer availability .
Example: One segment may carry 3 bytes, while another carries 5
bytes, but in reality, they can be much larger (hundreds or thousands of
bytes).
TCP Feature
Control Flags: URG, ACK, PSH, RST, SYN, FIN (used for different TCP
operations).Window Size: Defines the size of the sending TCP buffer.
Checksum: Ensures error-free transmission.
Urgent Pointer: Used when the URG flag is set.
Options: Additional configurations can be included.
TCP Segment Structure
TCP uses a buffer to store and send data efficiently.The PUSH flag
ensures data is immediately sent without waiting for the buffer to fill.
Some TCP implementations allow applications to enable or disable the
PUSH flag.
5. Flexibility in TCP Data Transmission : TCP allows both immediate and
delayed data transmission based on application needs.
Applications can choose whether to wait for more data or send it
immediately.
Urgent Data in TCP
The urgent pointer marks the first and last byte of the urgent data.
The application decides how to handle urgent data; TCP itself does not
process it differently.
TCP Connection Termination
(Three-Way Handshake)
A client can stop sending data but continue receiving from the server.
This is useful when one side is done sending but still expects data.
The connection remains open in one direction.
Connection Reset (RST Flag)
TCP uses two windows (send window and receive window) for each
direction of data transfer.
The send window in TCP is similar to the one used with the Selective-Repeat protocol,
but with some differences:
1. One difference is the nature of entities related to the window. The window size in
SR is the number of packets, but the window size in TCP is the number of bytes.
Although actual transmission in TCP occurs segment by segment, the variables that
control the window are expressed in bytes.
2. The second difference is that, in some implementations, TCP can store data
received from the process and send them later, but we assume that the sending
TCP is capable of sending segments of data as soon as it receives them from its
process.
3. Another difference is the number of timers. The theoretical Selective-Repeat protocol
may use several timers for each packet sent, but as mentioned before, the TCP protocol
uses only one timer.
Receive Window
The receive window closes when more bytes arrive from the sender.
The send window can shrink if the receiver defines a value for rwnd
that results in shrinking the window.
The limitation does not allow the right wall of the send window to move
to the left.
new ackNo + new rwnd ≥ last ackNo + last rwnd
The left side of the inequality represents the new position of the right
wall with respect to the sequence number space.
The right side shows the old position of the right wall.
The relationship shows that the right wall should not move to the left.
Window Shutdown
The receiver can temporarily shut down the window by sending a rwnd
of 0.
If the receiver does not want to receive any data from the sender for a
while.
In this case, the sender does not actually shrink the size of the window,
but stops sending data until a new advertisement has arrived.
Even when the window is shut down by an order from the receiver, the
sender can always send a segment with 1 byte of data.
This is called probing and is used to prevent a deadlock.
Silly Window Syndrome
A serious problem can arise in the sliding window operation when either
the sending application program creates data slowly or the receiving
application program consumes data slowly, or both.
Any of these situations results in the sending of data in very small
segments, which reduces the efficiency of the operation.
The inefficiency is even worse after accounting for the data-link layer
and physical-layer overhead. This problem is called the silly window
syndrome.
Syndrome created by the sender
The sending TCP may create a silly window syndrome if it is serving an application
program that creates data slowly.
Nagle found an elegant solution.
Nagle’s algorithm is simple: 1. The sending TCP sends the first piece of data it
receives from the sending application program even if it is only 1 byte.
2. After sending the first segment, the sending TCP accumulates data in the
output buffer and waits until either the receiving TCP sends an acknowledgment or
until enough data have accumulated to fill a maximum-size segment. At this time ,
sending TCP can send the segment.
3. Step 2 is repeated for the rest of the transmission. Segment 3 is sent
immediately if an acknowledgment is received for segment 2, or if enough data
have accumulated to fill a maximum-size segment.
Syndrome created by the reciever
The receiving TCP may create a silly window syndrome if it is serving an application
program that consumes data slowly
Two solutions have been proposed to prevent the silly window syndrome created by an
application program that consumes data more slowly than they arrive.
Clark’s solution is to send an acknowledgment as soon as the data arrive, but to
announce a window size of zero until either there is enough space to accommodate a
segment of maximum size or until at least half of the receive buffer is empty.
The second solution is to delay sending the acknowledgment. This means that when a
segment arrives, it is not acknowledged immediately. The receiver waits until there is a
decent amount of space in its incoming buffer before acknowledging the arrived
segments.
The delayed acknowledgment prevents the sending TCP from sliding its window. After
the sending TCP has sent the data in the window, it stops. This kills the syndrome.
Error Control
The sending TCP maintains one retransmission time-out (RTO) for each
connection.
When the timer matures, i.e. times out, TCP resends the segment in the
front of the queue (the segment with the smallest sequence number)
and restarts the timer.
The value of RTO is dynamic in TCP and is updated based on the round-
trip time (RTT) of segments.
RTT is the time needed for a segment to reach a destination and for an
acknowledgment to be received.
Retransmission after Three Duplicate
ACK Segments
1. What is Congestion?
Occurs when too many packets are sent through a network, causing
packet loss and delays.
2. Why is Congestion Control Needed?
Prevents network overload.Ensures fair bandwidth usage among
users.Improves overall network efficiency and performance
TCP Congestion Control Mechanisms
.
a) Slow Start
Initially, TCP increases the Congestion Window (CWND) exponentially.Helps probe the
available bandwidth safely.
b) Congestion Avoidance
After reaching a threshold, TCP increases CWND linearly.Prevents sudden congestion by
gradually increasing traffic.
c) Fast Retransmit
If 3 duplicate ACKs are received, TCP assumes packet loss and retransmits it immediately.
d) Fast Recovery
Instead of restarting from scratch, TCP reduces CWND but avoids going back to the slow
start phase.
Advantages of TCP Congestion
Control
1. TCP Tahoe
Key Features:
Uses Slow Start, Congestion Avoidance, and Fast Retransmit.If packet loss
is detected (via timeout or 3 duplicate ACKs), it reduces CWND to 1 and
enters Slow Start again.
This drastic reduction slows down recovery but prevents congestion
collapse.
Drawback:
Resetting CWND to 1 after every packet loss is inefficient, especially in
high-bandwidth networks.
2. TCP Reno
Key Features:
Builds on Tahoe but introduces Fast Recovery to improve performance .
If 3 duplicate ACKs are received : Halves CWND instead of resetting it to 1.
Enters Fast Recovery to keep sending packets, avoiding Slow Start.
If packet loss is detected via timeout, it behaves like Tahoe (CWND=1).
Advantage : Recovers faster from packet loss than Tahoe, improving throughput.
Drawback : Not efficient when multiple packet losses occur in one window of
data.
3. TCP New Reno
Key Features : Improves Reno by handling multiple packet losses in one
congestion window .
Uses partial acknowledgments (partial ACKs) to detect lost packets and
retransmit without leaving Fast Recovery .
Helps recover from multiple losses without reducing CWND too
aggressively.
Advantage : Better performance in networks with high packet loss .
Drawback : Still relies on duplicate ACKs for detecting losses, which may
not work well in all cases.
TCP Timers
1. Retransmission Timer
Used to detect packet loss and trigger retransmission .
Set based on the Round Trip Time (RTT) between sender and receiver.
If no ACK is received within the timeout period, TCP retransmits the
packet.
2. Persistence Timer