Lab Assign 5

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

LAB ASSIGNMENT- 5

COMPUTER NETWORKS
KIRAN TRIPATHY
22BDS0172

Question 3 : Analyze the role of flow control and congestion control in TCP. Explain the
mechanisms TCP uses to avoid congestion, such as the slow start and congestion avoidance
algorithms.

Answer:

Role of Flow Control and Congestion Control in TCP

Flow Control and Congestion Control are two critical mechanisms in TCP
(Transmission Control Protocol) that ensure efficient and reliable data transmission
over the network.

1. Flow Control :
- The primary purpose of flow control is to prevent the sender from overwhelming
the receiver by sending more data than it can process or store.
- TCP achieves flow control through the use of a receiver window (often called the
receive window size ), which informs the sender how much buffer space is available at
the receiver. The sender adjusts its transmission rate to ensure it does not exceed the
receiver’s capacity.

2. Congestion Control :
- Congestion control aims to prevent the network itself from becoming overwhelmed,
as excessive data transmission can lead to packet loss, increased delays, and reduced
throughput. Unlike flow control, which is concerned with the capacity of the receiver,
congestion control focuses on the state of the entire network.

Mechanisms TCP Uses to Avoid Congestion

TCP implements a set of algorithms and mechanisms to detect and avoid congestion in
the network. The two key algorithms used for congestion control are Slow Start and
Congestion Avoidance . Together with additional mechanisms like Fast Retransmit
and Fast Recovery , these ensure that TCP can adapt to network conditions
dynamically.

1. Slow Start :
- The slow start algorithm is used to probe the network for available capacity in a
controlled manner, rather than sending a large burst of data all at once.
- When a new TCP connection is established or after a packet loss, the sender starts
with a congestion window (cwnd) of 1 Maximum Segment Size (MSS).
- For each acknowledgment (ACK) received, the congestion window is increased
exponentially (doubled) for each round-trip time (RTT). This continues until the slow
start threshold (ssthresh) is reached or packet loss is detected, signaling potential
congestion.

Advantages : It helps avoid overwhelming the network in the early stages of a


connection when the available bandwidth is unknown.
Drawback: If the network is already congested, slow start can still cause packet
loss, but it prevents the sender from immediately sending a large volume of data.

2. Congestion Avoidance :
- Once the congestion window reaches the slow start threshold (ssthresh), TCP
transitions to the congestion avoidance phase, where it increases the congestion
window more slowly to avoid overwhelming the network.
- Instead of exponential growth, the congestion window grows linearly by one MSS
for each RTT that passes without packet loss.
- This gradual increase allows TCP to cautiously probe for available bandwidth while
avoiding congestion.

3. Fast Retransmit and Fast Recovery :


- When TCP detects packet loss (usually indicated by duplicate ACKs), it enters the
Fast Retransmit phase, where it retransmits the missing segment without waiting for
the retransmission timeout.
- In the Fast Recovery phase, instead of reducing the congestion window
drastically as in earlier implementations of TCP (which would revert to slow start), TCP
reduces the window by half and continues to transmit new data. This avoids the need
to start the congestion window from a very low value and allows for quicker recovery
from packet loss.

Summary of TCP Congestion Control:


- Slow Start : Begins with a small congestion window and increases exponentially
until a threshold is reached.
- Congestion Avoidance : Once the threshold is reached, the congestion window
grows linearly to avoid congesting the network.
- Fast Retransmit : Detects packet loss early using duplicate ACKs and retransmits
lost packets.
- Fast Recovery : Halves the congestion window after packet loss but continues
transmitting to recover quickly from loss without fully resetting the window size.

Conclusion:
Flow control and congestion control in TCP work together to manage both the receiver's
capacity and the network's capacity. The flow control prevents overloading the
receiver, while congestion control prevents overloading the network, with TCP's slow
start, congestion avoidance, fast retransmit, and fast recovery being key mechanisms to
dynamically adjust to varying network conditions.

You might also like