TCP-III: Congestion Control and Connection Closing

6
0

TCP Congestion Control

Even if the receiver is ready for more data, the network itself may not be able to carry unlimited traffic. If too much data is injected too quickly, routers and links may become congested, causing queue buildup, delay, and packet loss.

TCP handles this using congestion control. The sender maintains a congestion window, called cwnd, and adjusts it based on what the network seems able to support.

Important congestion-control ideas include:

  • Slow start: TCP begins cautiously and increases the sending rate quickly at first

  • Congestion avoidance: After a threshold, growth becomes slower and more controlled

  • Fast retransmit: Loss is inferred using duplicate ACKs

  • Fast recovery: TCP reduces the sending rate without always restarting from the very beginning

TCP assumes that loss can be a sign of congestion, so when loss occurs, the sender reduces its transmission aggressiveness.

TCP Congestion Control

TCP Congestion Control

Slow Start and Congestion Avoidance

The name slow start sounds gentle, but its growth is actually quite fast. TCP begins with a small congestion window and increases it as acknowledgments arrive. This lets the sender test how much traffic the network can handle.

Once the sender reaches a threshold called ssthresh, TCP usually enters congestion avoidance mode. In this phase, the congestion window still grows, but more slowly.

The idea is simple:

  • Start carefully

  • Increase transmission rate while things look healthy

  • Become more cautious as the load grows

  • Reduce the rate when congestion is detected

This behavior helps TCP balance efficiency with network stability.

Flow Control vs Congestion Control

These two ideas are related, but they are not the same.

Aspect

Flow Control

Congestion Control

Main goal

Protect the receiver

Protect the network

Controlled by

Receiver capacity

Network conditions

Key concept

Receive window (rwnd)

Congestion window (cwnd)

Problem avoided

Receiver buffer overflow

Network overload and packet loss

The sender must respect both limits. In practice, the amount of data TCP can send is influenced by whichever is smaller.

A useful mental rule is:

  • Flow control: Can the receiver handle more?

  • Congestion control: Can the network handle more?

TCP Connection Closing

TCP does not usually end communication abruptly. It closes the connection in an organized way so both sides know that all data has been exchanged.

The normal connection termination process typically uses FIN and ACK flags.

A common closing sequence is:

  • One side sends FIN

  • The other side sends ACK

  • The other side later sends its own FIN

  • The first side replies with ACK

This is often called the four-way close because shutting down one direction and the other direction may happen separately.

TCP supports full-duplex communication, so each side closes its sending path independently. That is why connection closing is often a little more detailed than connection setup.

TCP Connection Closing

TCP Connection Closing

Common Uses of TCP

TCP is preferred wherever correct delivery matters more than low delay.

Some common uses are:

  • HTTP and HTTPS: Reliable web page and web API transfer

  • FTP and file download systems: Complete file delivery matters

  • Email transfer: Messages should arrive correctly

  • Database communication: Queries and responses must stay accurate

  • Remote administration and enterprise apps: Ordered reliable communication is essential

If the application cannot tolerate missing or scrambled data, TCP is usually the safer choice.

CS Core

Read Similar Blogs

Comments0