1. Home
  2. Explore
  3. Computer Science
  4. TCP Receive and Congestion Windows

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

TCP Receive and Congestion Windows

TCP Windows and Packet-Trace Analysis

TCP uses windows to regulate how much data can be sent and received. Understanding the two main windows—the receive window and the congestion window—helps explain why a transfer may pause even when the network link appears fast.


1. The two TCP windows

Receive window: how much the receiver can accept

The receive window, often written as rwnd, is advertised by the receiver in TCP packets. It tells the sender how much additional data the receiver can accept without overflowing its receive buffer.

A receiver’s advertised window reflects available buffer space in its TCP receive buffer. That space may fill when data arrives faster than the receiving application reads it. As the application consumes buffered data, space becomes available and the receiver can advertise a larger window again.

In a pipe-and-bucket analogy:

  • The sender pours data into the pipe.

  • The receiver’s bucket represents its available receive buffer.

  • The receive window tells the sender how much room remains in that bucket.

  • If the bucket is nearly full, the sender must slow down or pause until room becomes available.

A receive window of zero is a zero window: the receiver is telling the sender that it currently cannot accept more data. The sender must stop transmitting new data until the receiver advertises a nonzero window again.

Congestion window: how much the sender is willing to put into the network

The congestion window, often written as cwnd, is a sender-side limit on the amount of unacknowledged data that may be in flight. It helps the sender avoid overwhelming the network.

Unlike the receive window, the congestion window is not directly advertised in TCP packet headers. It is maintained internally by the sending TCP stack, so it generally has to be inferred from packet behavior and acknowledgments.

The sender is constrained by both windows:

permitted in-flight data≤min⁡(rwnd,cwnd)\text{permitted in-flight data} \leq \min(\text{rwnd}, \text{cwnd})permitted in-flight data≤min(rwnd,cwnd)

The smaller window is the limiting one:

  • A large congestion window does not help if the receiver has little buffer space.

  • A large receive window does not help if the sender’s congestion window is small.

  • The application must also have data ready for TCP to send.

The receive window protects the receiver’s buffer; the congestion window protects the network from excessive traffic.


2. Why network capacity matters

An idealized transfer might assume unlimited bandwidth, negligible delay, no packet loss, and unlimited buffer space at both endpoints. Real networks have constraints, including:

  • Bandwidth limits on links along the route.

  • Latency, which delays acknowledgments and limits how quickly the sender learns that data arrived.

  • Packet loss, congestion, errors, and discards at routers, switches, or endpoints.

  • Buffer limits in network devices and host systems.

  • Different link speeds across a path, such as traffic crossing from a faster interface to a slower one.

  • Endpoint limits, including receive-buffer capacity and how quickly an application reads or produces data.

Consequently, a fast link at one endpoint does not prove that a transfer can run at that speed end to end. A transfer can also be limited by an application or TCP buffer even when the two machines are connected to fast links.


3. Diagnosing a receive-window limitation

Example: a slow database backup on a local network

A backup transfer between two servers on the same gigabit network took much of the night. At first, upgrading the links to a faster speed might seem like the obvious solution. However, a packet capture showed that many packets arrived with very small gaps, followed by recurring pauses of roughly 191919–202020 milliseconds.

A single delay of that size may seem minor. Repeated thousands of times over a long transfer, however, these small delays can substantially reduce throughput.

The important diagnostic question is not only how long was the delay? It is also how often did it happen, and what was the TCP state when it happened?

Reading the advertised receive window

In the example, the connection was not using TCP window scaling, so the advertised window values could be interpreted directly. With window scaling enabled, the value shown in a packet may need to be multiplied by the negotiated scale factor to obtain the effective window. If the handshake is missing from a capture, the scale factor may not be known.

The data receiver advertised an initially large window, then its advertised window decreased as data arrived. Each full-size data segment reduced the remaining available receive space. Eventually, the advertised window became smaller than a full-size segment. The sender sent one more segment that would fit, then paused until the receiver advertised more space.

When the receiving application consumed buffered data, the receiver advertised a larger window. The sender could then resume transmitting.

This pattern indicates that the receiver’s available buffer space is controlling the transfer. The receiver may not advertise a zero window; it can still cause pauses simply by advertising too little room for the sender’s next full-size segment.

Why the application can be responsible

TCP receives incoming data into buffers and makes it available to the application. If the application reads data slowly, the TCP receive buffer can fill. The receive window then shrinks, restricting the sender.

A larger receive buffer or a larger window-scale factor may postpone the problem by giving the receiver more room. But if the application continues to consume data too slowly, the larger buffer will eventually fill as well. The more direct remedy is to determine why the application is not reading data fast enough. That may require application-level tuning or help from the software vendor.

If the sender is already being limited by the receiver’s advertised window, upgrading the network link will not address the underlying bottleneck.

Window updates

A receiver may send a window update to announce that more buffer space is available. A packet-capture tool may label some packets as window updates, but that label depends on the packet’s contents and the tool’s rules. An acknowledgment that both acknowledges new data and advertises a changed window may not be labeled as a standalone window update.

The useful information is the advertised window value over time, not just the presence or absence of a particular analyzer label.


4. Visualizing a receive-window stall with a TCP trace graph

A TCP time-sequence graph can make the receive-window behavior easier to see.

  • The horizontal axis represents time.

  • The vertical axis represents TCP sequence number, which tracks the bytes in the stream.

  • The rising data trace shows sequence numbers of transmitted data.

  • An acknowledgment trace shows how much data the receiver has acknowledged.

  • A receive-window boundary indicates how far beyond the acknowledged data the receiver is currently prepared to accept data.

In an efficient transfer, the data trace should progress steadily upward as time passes. A steep, continuous rise indicates that data is moving quickly without long pauses.

If the receive-window boundary stops rising while incoming data continues, the gap between the data and the boundary shrinks. When the data reaches that boundary, the sender has exhausted the receive-window space and must wait. When the boundary moves upward again, the sender can transmit more data.

Thus, a repeating pattern of window opens → data flows → window fills → transfer pauses points to receive-window pressure. Packet-level window values help confirm what the graph suggests.


5. Congestion control and the congestion window

Why the sender does not transmit at full speed immediately

A sender cannot assume that the entire path can handle the speed of its own network interface. A server attached to a fast network may send through slower or more congested links before data reaches the receiver.

The congestion window limits how much unacknowledged data the sender puts into the network at one time. TCP uses this limit to probe the path carefully rather than flooding it immediately.

The congestion window is commonly expressed as a multiple of the maximum segment size (MSS). The MSS is the largest TCP payload segment the sender expects to transmit under the connection’s negotiated conditions.

Slow start

At the beginning of a connection or data transfer, many TCP implementations use slow start. The congestion window begins at a relatively small value. As acknowledgments arrive successfully, the sender increases the amount of data it can send.

In simplified terms, slow start grows the congestion window rapidly—roughly exponentially across round trips—until it reaches a threshold or congestion is detected. The exact initial value and detailed behavior depend on the TCP implementation and congestion-control algorithm.

A simplified progression might look like:

  1. Send a small number of segments.

  2. Receive acknowledgments.

  3. Increase the allowed amount of data in flight.

  4. Send a larger group of segments.

  5. Continue probing the network as acknowledgments arrive.

The sender can therefore pause while waiting for acknowledgments even when the receive window has ample space. Early in a transfer, those pauses may be part of normal slow-start behavior.

Congestion avoidance and loss response

After reaching a slow-start threshold, TCP generally increases the congestion window more cautiously, a phase commonly called congestion avoidance. The particular increase and loss-response rules depend on the congestion-control algorithm in use.

If the sender detects congestion—for example, through packet loss or retransmissions—it typically reduces its congestion window. This signals that the previous sending rate may have been too aggressive. TCP then attempts to continue without overwhelming the path.

A packet capture does not show the congestion-window value directly. Instead, an analyst infers its behavior from:

  • How much data is sent before acknowledgments arrive.

  • How the amount of in-flight data changes over time.

  • Whether the pattern resembles slow start or a steadier sending rate.

  • Whether loss and retransmissions are followed by a reduction in sending.

Interpreting a slow-start trace

A clean slow-start example often shows the sender increasing the number of full-size segments sent in successive bursts. The time between bursts may correspond to the network’s round-trip time, since the sender is waiting for acknowledgments before expanding its sending rate.

As slow start proceeds, the transmitted data should move upward rapidly on a TCP time-sequence graph, while remaining below the receiver’s window boundary. If the sender’s bursts become similar in size and the graph’s upward steps become consistent, the sender may have reached a threshold and be increasing more cautiously.

Other factors can also limit sending. For example, the application may not be supplying data quickly enough for TCP to send at the rate the network could otherwise support.


6. Distinguishing receive-window and congestion-window limits

The two types of limitation can produce pauses, but they have different causes.

Receive-window limitation

  • The receiver advertises a shrinking window.

  • Data approaches the receiver’s advertised-window boundary.

  • The sender pauses when the receiver has too little space.

  • The receiver resumes progress by advertising more available space.

Congestion-window limitation

  • The limit is maintained internally by the sender and is not directly advertised.

  • The sender may transmit a limited amount, wait for acknowledgments, and then increase its sending rate.

  • Slow start and congestion avoidance influence the amount of data in flight.

  • Packet loss or retransmissions can cause the sender to reduce its sending rate.

A useful diagnosis combines packet-level window values, acknowledgment timing, retransmissions, and a TCP time-sequence graph. No single pause should automatically be attributed to the network or to either endpoint.


7. Measuring delays in Wireshark

Capture-wide delta time versus time within a TCP stream

A capture-wide delta time measures the time since the immediately preceding captured frame. In a capture containing many simultaneous connections, the preceding frame may belong to an entirely different TCP conversation. Sorting on this value can therefore produce a large delay that is not meaningful for the connection being investigated.

A more useful measure for locating pauses is the time since the previous frame in the same TCP stream. This keeps the timing in the context of that connection and avoids having to isolate every conversation before sorting.

If the relevant TCP timestamp field is not available, Wireshark’s TCP protocol preferences can be used to enable conversation timestamps. A column for the time since the previous frame in the TCP stream can then be added and sorted to identify unusually long gaps.

Separating client think time from server response time

A long gap between packets does not by itself identify which side caused the delay. The direction and packet type matter.

  • A delay before a client sends its next request may represent client think time or application processing.

  • A delay between a request and the corresponding server response may indicate server-side processing time, a network problem, or another delay on the path.

  • Regular intervals, such as repeated keep-alive or timeout intervals, may reflect configured timers rather than slow application responses.

A practical method is to sort by time within the TCP stream, identify unusually long gaps, and then inspect the packet sequence around each gap. For server-performance complaints, a long interval from a request to a response is more relevant than a long interval before the client sends its next request.


8. Case study: retransmissions caused by a packet-size problem

Observed behavior

A client could reach an LDAP server, but each attempt to retrieve a new file paused for roughly 202020–303030 seconds before the transfer began. A client-side packet capture showed:

  1. The TCP handshake completed.

  2. The client sent a search request.

  3. The server sent a small amount of data.

  4. A larger earlier segment appeared to be missing.

  5. The connection then paused before data flow resumed.

The sequence numbers and acknowledgment information showed that the client had received a later portion of the server’s data but was still missing an earlier segment. A selective acknowledgment (SACK) can report both the contiguous data received and a later block of data received beyond the missing segment. This lets the sender identify which range remains missing without retransmitting data that has already arrived.

Retransmission backoff

A server-side capture explained the delay. The server sent large segments, but they were not acknowledged successfully. Because the connection was at an early stage and had not received enough duplicate acknowledgments to trigger a fast retransmission, the server had to wait for its retransmission timer.

At the start of a connection, the retransmission timeout may be relatively long. If retransmissions continue to fail, TCP can increase the waiting interval through exponential backoff. The observed sequence included waits of about 333, 666, and 121212 seconds.

This explains how a brief initial packet-size problem can produce a much longer application-visible delay: the sender repeatedly waits for its retransmission timer before trying again.

Fast retransmission generally depends on receiving enough duplicate acknowledgments to indicate that a segment is missing. If too little data has been sent to generate those acknowledgments, the sender may have to rely on the retransmission timeout instead.

Why smaller segments succeeded

After larger segments failed repeatedly, the server eventually sent a smaller segment of about 536536536 bytes. That segment was acknowledged, and the transfer began to make progress. This size-dependent behavior suggests that the problem involved packet size or the path’s ability to carry larger packets, rather than a complete loss of connectivity.

A possible cause is a path-MTU problem or a middlebox that handles larger packets incorrectly. A path may have a smaller effective packet-size limit than the endpoints expect. If large packets are dropped and the relevant network feedback does not reach the sender, the connection can stall while the sender retries.

For IPv4 connections where no MSS option is available, the traditional default MSS is 536536536 bytes. The case’s successful small segment was consistent with that fallback size.

Understanding MSS advertisements and MSS clamping

Each endpoint’s MSS advertisement tells the other endpoint the largest TCP payload segment it is prepared to receive. The advertisement is carried in the SYN packet during connection setup. MSS is directional in this sense: an MSS value in one endpoint’s SYN informs the peer about the sender’s receive limit.

A middlebox may perform MSS clamping, modifying MSS values in SYN packets so that endpoints use segment sizes suitable for the path. The modification must be applied to the SYN that informs the sender in the affected direction; a mismatch in captures can help reveal that a router or firewall changed the advertised value.

In the example, the captures showed MSS values differing between the endpoints’ views, suggesting that a gateway was modifying the handshake. The general lesson is to compare the MSS values as seen on both sides of the path and verify that the clamp is applied in the correct direction. A mismatch alone is not enough to identify the exact cause; it should be evaluated alongside the missing segments, retransmissions, and packet sizes.

Troubleshooting approach

A useful investigation proceeds from the visible symptom to the packet evidence:

  1. Measure the delay between the request and the start of useful data.

  2. Inspect sequence and acknowledgment numbers to identify missing data.

  3. Check for SACK information showing later data received around a gap.

  4. Look for retransmissions and note whether they follow duplicate acknowledgments or retransmission timeouts.

  5. Compare segment sizes for failed and successful transmissions.

  6. Compare MSS values in the handshake as observed at relevant points on the path.

  7. Inspect routers, firewalls, and other middleboxes for MSS clamping or packet-size handling.

  8. Correct the path or MSS configuration so the sender uses segments the path can carry reliably.


9. Practical diagnostic principles

  • A fast endpoint link does not guarantee a fast end-to-end transfer. The limiting factor may be elsewhere in the path or at an endpoint.

  • Repeated small pauses can accumulate into a major delay. Their frequency and context matter as much as their individual duration.

  • The receive window is visible in packet headers; the congestion window is not. The latter must be inferred from sender behavior.

  • Check whether the receiver is advertising enough space. A shrinking receive window can reveal buffer pressure even if it never reaches zero.

  • Use sequence numbers, acknowledgments, and retransmissions together. They help distinguish normal acknowledgment timing from data loss and retransmission-timeout delays.

  • Keep timing measurements within the relevant TCP stream. Capture-wide gaps can be misleading when many conversations are interleaved.

  • A successful smaller segment after larger segments fail is a clue. It can point toward a path MTU, MSS, or middlebox problem.

  • Identify the actual limiting component before changing infrastructure. A larger link, larger buffer, or different backup method may hide a symptom without explaining its cause.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent