Bird
Raised Fist0
Interview Prepcomputer-networksmediumAmazonGoogleFlipkartCRED

TCP Flow Control - Sliding Window & Congestion Control (AIMD)

Choose your preparation mode3 modes available
🎯
TCP Flow Control - Sliding Window & Congestion Control (AIMD)
mediumNETWORKSAmazonGoogleFlipkart

Imagine streaming a live video where the sender must adjust its sending rate dynamically to avoid overwhelming the network or the receiver’s buffer, ensuring smooth playback without pauses or crashes.

💡 Beginners often confuse flow control with congestion control, thinking both regulate the same thing, but they actually address different problems-receiver buffer capacity vs. network congestion.
📋
Interview Question

Explain how TCP uses sliding window for flow control and how AIMD (Additive Increase Multiplicative Decrease) is applied in TCP congestion control. What are the differences between flow control and congestion control in TCP?

Sliding window mechanism for flow controlTCP congestion control using AIMDDifference between flow control and congestion control
💡
Scenario & Trace
ScenarioA client downloads a large file from a server over a network with variable bandwidth and latency.
1. Server sends data packets up to the receiver’s advertised window size (flow control). 2. Receiver acknowledges received packets and updates the window size based on its buffer availability. 3. Server increases its congestion window gradually (additive increase) when acknowledgments arrive without loss. 4. Upon detecting packet loss (timeout or triple duplicate ACKs), server reduces congestion window multiplicatively (multiplicative decrease) to avoid network congestion. 5. This cycle repeats, balancing throughput and network stability.
ScenarioTwo processes communicate over TCP where the receiver’s buffer is small but the network is fast.
1. Receiver advertises a small window size limiting sender’s outstanding unacknowledged data (flow control). 2. Sender respects this window and sends only allowed data. 3. Even if network can handle more data, sender cannot exceed receiver’s window, preventing buffer overflow. 4. Congestion control mechanisms operate independently to avoid network congestion.
  • Receiver’s advertised window size is zero → sender must stop sending and periodically probe for window update
  • Network congestion causes packet loss → triggers multiplicative decrease in congestion window
  • Receiver’s buffer is large but network is congested → flow control window is large but congestion window limits throughput
⚠️
Common Mistakes
Confusing flow control with congestion control

Interviewer thinks candidate lacks fundamental understanding of TCP mechanisms.

✅ Remember flow control manages receiver buffer limits; congestion control manages network capacity.

Assuming sliding window alone controls congestion

Interviewer doubts candidate’s grasp of network dynamics and TCP’s dual-window approach.

✅ Clarify that sliding window is for flow control; congestion window and AIMD handle congestion.

Not mentioning multiplicative decrease on packet loss

Interviewer suspects incomplete knowledge of AIMD and TCP’s congestion response.

✅ Always include that congestion window halves on loss to reduce congestion.

Ignoring zero window size scenario

Interviewer thinks candidate misses important edge cases affecting transmission.

✅ Explain that sender must stop sending and probe periodically until window opens.

🧠
Basic Definition - What It Is
💡 This level covers the fundamental concepts you must know to answer basic interview questions on TCP flow and congestion control.

Intuition

TCP uses sliding window to ensure the receiver is not overwhelmed, and AIMD to adjust sending rate based on network conditions.

Explanation

TCP flow control uses a sliding window mechanism where the receiver advertises how much data it can accept, preventing buffer overflow. The sender can only send data within this window before waiting for acknowledgments. Congestion control, on the other hand, manages the sender’s rate to avoid overwhelming the network. AIMD is a strategy where the sender increases its congestion window additively when the network is stable and decreases it multiplicatively upon detecting congestion, balancing throughput and fairness.

Memory Hook

💡 Think of flow control as the receiver holding a 'bucket' that limits how much water (data) it can hold, while congestion control is the sender adjusting the faucet flow based on pipe pressure.

Interview Questions

❓ What is the purpose of the sliding window in TCP?
  • It controls the amount of data the sender can transmit before receiving an acknowledgment.
  • It prevents the receiver’s buffer from overflowing.
❓ What does AIMD stand for and why is it used?
  • Additive Increase Multiplicative Decrease.
  • Used to adjust the congestion window to probe for available bandwidth and reduce sending rate on congestion.
⏱
Depth Level
Interview Time30 seconds
Depthbasic

Covers fundamental definitions and purpose; sufficient for screening rounds or quick conceptual questions.

Interview Target: Minimum floor - never go below this

Knowing only this will help you clear initial rounds but may not suffice for detailed technical discussions.

🧠
Mechanism Depth - How It Works
💡 This level explains the internal workings and interplay between flow control and congestion control, expected in product company interviews.

Intuition

TCP dynamically manages two windows - the receiver’s advertised window for flow control and the congestion window for network conditions - combining them to decide how much data to send.

Explanation

The sliding window flow control mechanism allows the receiver to advertise a window size indicating how many bytes it can accept without overflow. The sender maintains a send window limited by the minimum of the receiver’s advertised window and the congestion window. The congestion window is adjusted using AIMD: it increases linearly (additive increase) each round-trip time when no loss is detected, probing for more bandwidth, and decreases multiplicatively (usually halving) upon detecting packet loss, signaling congestion. TCP also uses slow start to exponentially increase the congestion window initially until it reaches a threshold, then switches to AIMD. This dual-window approach ensures that the sender neither overwhelms the receiver nor the network. The interaction between these windows determines the actual sending rate.

Memory Hook

💡 Imagine driving a car where the receiver’s window is the speed limit set by the road (receiver’s capacity), and congestion control is the driver adjusting speed based on traffic conditions (network congestion).

Interview Questions

❓ How does TCP decide the amount of data to send at any time?
  • It uses the minimum of the receiver’s advertised window and the congestion window.
  • The sender cannot send more data than allowed by either window.
❓ What happens to the congestion window when packet loss is detected?
  • It decreases multiplicatively, typically halving the window size.
  • This reduces sending rate to alleviate congestion.
❓ Explain the slow start phase in TCP congestion control.
  • Initially, congestion window grows exponentially to quickly find available bandwidth.
  • Once a threshold is reached, it switches to additive increase.
⏱
Depth Level
Interview Time2-3 minutes
Depthintermediate

Demonstrates understanding of internal TCP mechanisms and their interplay; suitable for FAANG on-site interviews.

Interview Target: Target level for FAANG on-sites

Mastering this level distinguishes you from most candidates and prepares you for deep technical discussions.

📊
Explanation Depth Levels
💡 Choose your explanation depth based on interview stage and company expectations.
LevelInterview TimeSuitable ForRisk
Basic Definition30sScreening call or quick conceptual questionsToo shallow for on-site interviews; may fail detailed technical probes
Mechanism Depth2-3 minutesOn-site interviews at product companies like FAANGRequires good understanding; insufficient detail may lose points
💼
Interview Strategy
💡 Use this guide to structure your explanation clearly and confidently before every mock or real interview.

How to Present

Start with a clear definition of flow control and congestion control.Give a relatable analogy or example to illustrate the concepts.Explain the sliding window mechanism and how AIMD adjusts the congestion window.Discuss edge cases like zero window size and packet loss scenarios.

Time Allocation

Definition: 30s → Example: 1min → Mechanism: 2min → Edge cases: 30s. Total ~4min

What the Interviewer Tests

Interviewer tests your ability to distinguish flow control from congestion control, explain their mechanisms, and reason about their interaction and edge cases.

Common Follow-ups

  • What happens if the receiver’s window size is zero?
  • How does TCP recover from congestion after multiplicative decrease?
💡 These follow-ups check your understanding of TCP’s robustness and recovery mechanisms.
🔍
Pattern Recognition

When to Use

When asked about TCP’s reliability, performance optimization, or network behavior under load.

Signature Phrases

'Explain TCP flow control and congestion control''Compare sliding window and congestion window''What happens when packet loss occurs in TCP?'

NOT This Pattern When

Similar Problems

Practice

(1/5)
1. In which scenario is the TCP sequence number most critical for ensuring reliable data transfer?
easy
A. When the receiver needs to reorder out-of-sequence packets before delivering data to the application
B. When the sender wants to detect duplicate acknowledgments to trigger fast retransmission
C. When the receiver uses it to calculate the retransmission timeout (RTO)
D. When the sender uses it to encrypt the data payload for security

Solution

  1. Step 1: Understand the role of TCP sequence numbers in packet ordering

    TCP sequence numbers uniquely identify bytes in the data stream, allowing the receiver to reorder packets that arrive out of order.
  2. Step 2: Analyze each option

    When the receiver needs to reorder out-of-sequence packets before delivering data to the application is correct because reordering depends on sequence numbers. When the sender wants to detect duplicate acknowledgments to trigger fast retransmission relates to ACKs, not sequence numbers directly. When the receiver uses it to calculate the retransmission timeout (RTO) is incorrect because RTO calculation uses RTT estimates, not sequence numbers. When the sender uses it to encrypt the data payload for security is unrelated to sequence numbers.
  3. Final Answer:

    Option A -> Option A
  4. Quick Check:

    Sequence numbers enable ordering, not encryption or RTO calculation.
Hint: Sequence numbers order bytes; ACKs confirm receipt.
Common Mistakes:
  • Confusing sequence numbers with ACK numbers
  • Thinking sequence numbers affect RTO calculation
  • Assuming sequence numbers relate to encryption
2. You are designing a live video streaming app where minimal delay is critical, and occasional frame loss is acceptable. Which transport protocol is most suitable?
easy
A. TCP, because it uses congestion control to avoid packet loss
B. TCP, because it guarantees delivery and order of packets
C. UDP, because it provides faster transmission without waiting for acknowledgments
D. UDP, because it establishes a connection before sending data

Solution

  1. Step 1: Identify the key requirement -- minimal delay with acceptable occasional loss

    Live video streaming prioritizes speed over perfect reliability.
  2. Step 2: Analyze TCP characteristics

    TCP guarantees delivery and order but introduces delay due to acknowledgments and retransmissions.
  3. Step 3: Analyze UDP characteristics

    UDP is connectionless and does not wait for acknowledgments, enabling faster transmission at the cost of possible packet loss.
  4. Step 4: Evaluate options

    UDP, because it provides faster transmission without waiting for acknowledgments correctly matches the scenario needs. TCP options prioritize reliability over speed. UDP does not establish a connection before sending data, so that option is incorrect.
  5. Final Answer:

    Option C -> Option C
  6. Quick Check:

    UDP is preferred for real-time applications where speed matters more than reliability.
Hint: Use UDP for speed when some loss is okay; TCP for reliability when loss is not acceptable.
Common Mistakes:
  • Assuming TCP is always better because it guarantees delivery
  • Believing UDP establishes a connection like TCP
  • Confusing congestion control with speed priority
3. Why might DHCP not be suitable for assigning IP addresses in a network with extremely high client churn and very short connection durations?
medium
A. Because the overhead of frequent DHCP Discover and Request messages can cause network congestion
B. Because DHCP cannot assign IP addresses dynamically in such environments
C. Because DHCP servers do not support IP address leasing
D. Because clients must manually configure IP addresses in such cases

Solution

  1. Step 1: Understand DHCP overhead

    Each new client connection triggers the DORA sequence, which adds network traffic.
  2. Step 2: Analyze impact of high churn

    Frequent IP requests can overload the DHCP server and increase broadcast traffic, causing congestion.
  3. Step 3: Evaluate other options

    Because DHCP cannot assign IP addresses dynamically in such environments is false; DHCP is designed for dynamic assignment. Because DHCP servers do not support IP address leasing is incorrect; DHCP supports leasing. Because clients must manually configure IP addresses in such cases is unrelated to DHCP limitations.
  4. Final Answer:

    Option A -> Option A
  5. Quick Check:

    High churn leads to excessive DHCP message overhead.
Hint: High churn -> many DHCP messages -> potential congestion
Common Mistakes:
  • Believing DHCP cannot assign dynamically in such cases
  • Confusing DHCP leasing with static assignment
  • Assuming manual configuration is required when DHCP is unsuitable
4. Which of the following statements about IPv6 headers is INCORRECT?
medium
A. IPv6 headers have a fixed length of 40 bytes, simplifying processing
B. IPv6 headers include a checksum field to ensure header integrity
C. IPv6 removes the header checksum present in IPv4 to reduce processing overhead
D. IPv6 headers support extension headers to add optional information

Solution

  1. Step 1: Recall IPv6 header structure

    IPv6 headers have fixed length and no checksum field.
  2. Step 2: Analyze options

    IPv6 headers have a fixed length of 40 bytes, simplifying processing is correct; IPv6 headers are fixed at 40 bytes. IPv6 headers include a checksum field to ensure header integrity is incorrect; IPv6 does not have a checksum field. IPv6 removes the header checksum present in IPv4 to reduce processing overhead is correct; checksum was removed to speed up processing. IPv6 headers support extension headers to add optional information is correct; extension headers provide optional info.
  3. Final Answer:

    Option B -> Option B
  4. Quick Check:

    IPv6 relies on upper-layer checksums, not header checksum.
Hint: IPv6 headers have no checksum field [OK]
Common Mistakes:
  • Assuming IPv6 headers have checksums like IPv4
  • Confusing extension headers with fixed header fields
5. Why might the TCP three-way handshake introduce latency, and when could this be a disadvantage?
medium
A. Because it requires multiple round-trip times before data transfer, causing delay in time-sensitive applications
B. Because it encrypts all packets during handshake, increasing processing time
C. Because it uses UDP packets which are slower than TCP packets
D. Because it requires the server to send data before the client can send any

Solution

  1. Step 1: Identify handshake latency cause

    The handshake requires at least one full round-trip time (RTT) before data can be sent, introducing delay.
  2. Step 2: Analyze options

    Because it requires multiple round-trip times before data transfer, causing delay in time-sensitive applications correctly states the latency due to multiple RTTs, which can be problematic for real-time or low-latency applications. Because it encrypts all packets during handshake, increasing processing time is incorrect; encryption is separate from handshake. Because it uses UDP packets which are slower than TCP packets is false; handshake uses TCP packets, not UDP. Because it requires the server to send data before the client can send any is incorrect; the client sends data after handshake completes.
  3. Final Answer:

    Option A -> Option A
  4. Quick Check:

    Handshake latency = multiple RTTs before data flow.
Hint: Handshake latency = waiting for multiple packet exchanges before data
Common Mistakes:
  • Confusing handshake with encryption overhead
  • Thinking handshake uses UDP packets
  • Believing server sends data first
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard