Bird
Raised Fist0
Interview Prepcomputer-networksmediumGoogleAmazonFlipkartZepto

TCP Sequence Numbers, ACKs & Retransmission (RTO)

Choose your preparation mode3 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
🎯
TCP Sequence Numbers, ACKs & Retransmission (RTO)
mediumNETWORKSGoogleAmazonFlipkart

Imagine sending a long letter through a friend who can only carry small envelopes. You number each envelope and wait for your friend to confirm receipt before sending more. This is how TCP ensures reliable data delivery over the internet.

💡 Beginners often confuse sequence numbers with acknowledgment numbers or think retransmission happens immediately after a lost packet without understanding the timeout mechanism.
📋
Interview Question

Explain how TCP uses sequence numbers and acknowledgments to ensure reliable data transfer, and describe the role of retransmission timeout (RTO) in handling lost packets.

TCP sequence numbers and their role in ordering bytesAcknowledgment numbers and cumulative ACKsRetransmission Timeout (RTO) and its adaptive calculation
💡
Scenario & Trace
ScenarioA client sends a file to a server over TCP, but one packet is lost in transit.
1. Client sends segments with sequence numbers 1-1000, 1001-2000, 2001-3000. 2. Server receives first two segments and sends ACK with acknowledgment number 2001 (expecting next byte 2001). 3. The third segment (2001-3000) is lost. 4. Client waits for ACK; no ACK for third segment arrives before RTO expires. 5. Client retransmits segment 2001-3000. 6. Server receives retransmission and sends ACK 3001 confirming receipt of all bytes up to 3000.
ScenarioTwo TCP endpoints establish a connection and exchange data with overlapping sequence numbers due to retransmission.
1. Connection established with initial sequence numbers. 2. Sender transmits data segments with sequence numbers 1-500, 501-1000. 3. ACKs received for both segments. 4. Sender retransmits segment 501-1000 due to suspected loss. 5. Receiver discards duplicate bytes and sends cumulative ACK for next expected byte 1001.
  • What happens if duplicate ACKs are received before RTO expires?
  • How does TCP handle sequence number wrap-around after reaching maximum value?
  • What if the retransmitted packet is also lost multiple times?
⚠️
Common Mistakes
Confusing sequence numbers with acknowledgment numbers

Interviewer doubts candidate’s understanding of TCP data flow

Clarify that sequence numbers label bytes sent, ACK numbers indicate next expected byte

Assuming retransmission happens immediately after a lost packet

Interviewer notes lack of knowledge about timeout and adaptive RTO

Explain retransmission occurs only after RTO expires or fast retransmit triggers

Ignoring cumulative nature of ACKs and treating each ACK as individual confirmation

Candidate misses efficiency and flow control aspects of TCP

Emphasize ACK number acknowledges all bytes up to that point cumulatively

Not mentioning adaptive calculation of RTO based on RTT

Shows incomplete understanding of TCP’s robustness to network variability

Describe RTT measurement and variance used to adjust RTO dynamically

🧠
Basic Definition - What It Is
💡 This level covers the fundamental purpose and roles of sequence numbers, ACKs, and retransmission in TCP.

Intuition

TCP uses sequence numbers to label bytes and acknowledgments to confirm receipt, enabling reliable data transfer.

Explanation

TCP assigns a unique sequence number to each byte of data sent. The receiver uses acknowledgment numbers to inform the sender which bytes have been received successfully. If the sender does not receive an acknowledgment within a certain timeout period (RTO), it retransmits the unacknowledged data to ensure reliability. This mechanism helps TCP provide ordered, reliable delivery over an unreliable network.

Memory Hook

💡 Think of TCP sequence numbers as page numbers in a book and ACKs as a reader telling the author which pages they've read.

Interview Questions

What is the purpose of TCP sequence numbers?
  • They uniquely identify each byte in the data stream
  • Help the receiver reorder segments and detect duplicates
What triggers TCP retransmission?
  • Timeout expiration (RTO) without receiving ACK
  • Possibly duplicate ACKs indicating packet loss
Depth Level
Interview Time30 seconds
Depthbasic

Covers fundamental definitions and roles; sufficient for screening rounds.

Interview Target: Minimum floor - never go below this

Knowing only this will help pass initial screens but not detailed technical interviews.

🧠
Mechanism Depth - How It Works
💡 This level explains the internal workings of sequence numbering, cumulative acknowledgments, and adaptive retransmission timeout.

Intuition

TCP maintains a sliding window of sequence numbers and uses ACKs to slide the window forward; retransmission timeout is dynamically calculated based on round-trip time estimates.

Explanation

TCP sequence numbers label each byte in the stream, allowing the receiver to reorder out-of-order segments and detect duplicates. The acknowledgment number sent by the receiver is cumulative, indicating the next expected byte. TCP uses a sliding window protocol to control flow and ensure reliable delivery. Retransmission Timeout (RTO) is calculated adaptively using round-trip time (RTT) measurements and variance to avoid premature or delayed retransmissions. When the RTO expires without receiving an ACK for sent data, TCP retransmits the unacknowledged segments. Additionally, TCP can perform fast retransmit triggered by receiving multiple duplicate ACKs, indicating likely packet loss before RTO expiry.

Memory Hook

💡 Imagine a conveyor belt (sequence numbers) moving packages; the receiver signals which package number it expects next (ACK), and if no signal arrives in time, the sender resends packages.

Interview Questions

How does TCP calculate retransmission timeout (RTO)?
  • Based on estimated round-trip time (RTT) and RTT variance
  • Uses algorithms like Jacobson/Karels for adaptive timeout
  • Adjusts dynamically to network conditions
What is the role of cumulative ACKs in TCP?
  • ACK number indicates next expected byte
  • Implicitly acknowledges all prior bytes
  • Helps sender slide the window forward
What happens when duplicate ACKs are received?
  • Indicates possible packet loss
  • Triggers fast retransmit before RTO expires
Depth Level
Interview Time2-3 minutes
Depthintermediate

Demonstrates understanding of TCP internals expected in FAANG on-sites.

Interview Target: Target level for FAANG on-sites

Mastering this level distinguishes you from most candidates.

📊
Explanation Depth Levels
💡 Choose depth based on interview stage and company expectations.
LevelInterview TimeSuitable ForRisk
Basic Definition30sScreening call or initial roundsToo shallow for on-site technical interviews
Mechanism Depth2-3 minutesOn-site interviews at FAANG and top tech companiesRequires solid understanding; missing details may cost points
💼
Interview Strategy
💡 Use this guide to structure your explanation clearly and confidently before interviews.

How to Present

Start with a concise definition of TCP sequence numbers and ACKs.Give a simple analogy or example to illustrate their purpose.Explain the mechanism of cumulative acknowledgments and retransmission timeout.Discuss common edge cases like duplicate ACKs and sequence number wrap-around.

Time Allocation

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

What the Interviewer Tests

Interviewer checks your grasp of reliable data transfer, timeout handling, and TCP’s adaptive mechanisms.

Common Follow-ups

  • What is fast retransmit and how does it differ from RTO-based retransmission?
  • How does TCP handle sequence number wrap-around?
💡 These follow-ups test deeper understanding and ability to handle tricky scenarios.
🔍
Pattern Recognition

When to Use

Asked when discussing TCP reliability, flow control, or troubleshooting network issues.

Signature Phrases

'Explain how TCP ensures reliable delivery''What is the role of sequence numbers and acknowledgments in TCP?''How does TCP handle lost packets?'

NOT This Pattern When

Similar Problems

Practice

(1/5)
1. Trace the encapsulation process when a user sends an email from their client application. Which sequence correctly represents the PDUs as data moves down the OSI layers?
easy
A. Data -> Packet -> Segment -> Frame -> Bits
B. Bits -> Frame -> Packet -> Segment -> Data
C. Data -> Segment -> Packet -> Frame -> Bits
D. Segment -> Data -> Packet -> Frame -> Bits

Solution

  1. Step 1: Identify PDU names per OSI layer

    Application Layer and Presentation Layer use 'Data', Transport Layer uses 'Segment', Network Layer uses 'Packet', Data Link Layer uses 'Frame', Physical Layer uses 'Bits'.
  2. Step 2: Follow encapsulation order

    Data is segmented, then packets are created, frames are formed, and finally bits are transmitted.
  3. Final Answer:

    Option C -> Option C
  4. Quick Check:

    Correct encapsulation order matches OSI layering [OK]
Hint: Data -> Segment -> Packet -> Frame -> Bits follows OSI top-down encapsulation [OK]
Common Mistakes:
  • Confusing order of PDUs
  • Mixing up Segment and Packet roles
  • Reversing encapsulation direction
2. Trace the sequence of events in TCP congestion control using AIMD when packet loss is detected via triple duplicate ACKs.
easy
A. Immediately stop sending data until timeout expires
B. Reset congestion window to 1 MSS and start slow start again
C. Cut congestion window to half, then increase linearly after each ACK
D. Ignore loss and continue increasing congestion window exponentially

Solution

  1. Step 1: Identify AIMD response to triple duplicate ACKs

    On triple duplicate ACKs, TCP performs fast retransmit and fast recovery, cutting congestion window to half.
  2. Step 2: Understand congestion window growth after loss

    After halving, TCP increases congestion window linearly (additive increase) to probe for available bandwidth.
  3. Step 3: Differentiate from timeout behavior

    Timeout triggers slow start (reset to 1 MSS), not triple duplicate ACKs.
  4. Step 4: Reject ignoring loss or stopping sending

    Ignoring loss or stopping immediately are incorrect TCP behaviors.
  5. Final Answer:

    Option C -> Option C
  6. Quick Check:

    Triple duplicate ACKs -> halve cwnd -> linear increase.
Hint: Triple duplicate ACKs -> fast retransmit + halve cwnd; timeout -> slow start.
Common Mistakes:
  • Confusing timeout and triple duplicate ACK loss signals
  • Assuming exponential growth continues after loss
  • Believing TCP stops sending immediately on loss
3. What is a key trade-off when setting a very long Time-To-Live (TTL) value for cached content on CDN edge servers?
medium
A. Long TTL improves cache hit rate but increases latency for users
B. Long TTL reduces origin server load but risks serving outdated content
C. Long TTL increases origin server load due to frequent cache refreshes
D. Long TTL causes edge servers to discard content too quickly

Solution

  1. Step 1: Understand TTL impact on cache freshness

    Long TTL means cached content stays longer before expiration.
  2. Step 2: Effect on origin server load

    Long TTL reduces requests to origin, lowering load.
  3. Step 3: Risk of stale content

    Long TTL risks serving outdated content if origin updates occur during TTL.
  4. Step 4: Analyze other options

    Long TTL increases origin server load due to frequent cache refreshes is incorrect because long TTL reduces origin load, not increases it. Long TTL improves cache hit rate but increases latency for users is wrong because longer TTL improves latency by increasing cache hits. Long TTL causes edge servers to discard content too quickly is false; long TTL means content is kept longer, not discarded quickly.
  5. Final Answer:

    Option B -> Option B
  6. Quick Check:

    Long TTL trades off freshness for reduced origin load.
Hint: Long TTL -> less origin load but stale content risk
Common Mistakes:
  • Confusing TTL effects on origin load
  • Assuming longer TTL increases latency
  • Misunderstanding TTL causes faster cache eviction
4. Which of the following statements about DHCP IP address leasing is INCORRECT?
medium
A. Once a lease expires, the IP address is immediately available for reassignment
B. Clients must renew their lease before it expires to keep the same IP address
C. DHCP servers can reclaim IP addresses from clients that do not renew leases
D. Leases help prevent IP address conflicts in the network

Solution

  1. Step 1: Understand lease expiration behavior

    When a lease expires, the IP address is not immediately available; there is usually a grace period before reassignment to avoid conflicts.
  2. Step 2: Analyze other options

    Options B, C, and D are correct statements about DHCP leasing behavior.
  3. Final Answer:

    Option A -> Option A
  4. Quick Check:

    Immediate reassignment after expiration is incorrect; DHCP uses timers to prevent conflicts.
Hint: Lease expiration ≠ instant IP reuse; timers prevent conflicts
Common Mistakes:
  • Assuming IPs are instantly reusable after lease expiry
  • Confusing lease renewal with release
  • Believing leases do not prevent conflicts
5. Which of the following statements about the OSI and TCP/IP models is INCORRECT?
medium
A. The OSI model has seven layers, while TCP/IP has four layers
B. The TCP/IP model includes a Presentation Layer separate from the Application Layer
C. The OSI model is a theoretical framework, whereas TCP/IP is a practical protocol suite
D. The Internet Layer in TCP/IP corresponds roughly to the Network Layer in OSI

Solution

  1. Step 1: Analyze each statement carefully

    Statement A is correct: OSI has 7 layers, TCP/IP has 4. Statement B is incorrect: TCP/IP does not have a separate Presentation Layer; it is combined with Application. Statement C is correct: OSI is theoretical, TCP/IP practical. Statement D is correct: Internet Layer maps to OSI's Network Layer.
  2. Final Answer:

    Option B -> Option B
  3. Quick Check:

    TCP/IP merges Presentation into Application Layer [OK]
Hint: TCP/IP merges Presentation into Application, no separate layer
Common Mistakes:
  • Assuming TCP/IP has all OSI layers distinctly
  • Confusing theoretical vs practical nature of models
  • Misaligning Internet and Network layers