Bird
Raised Fist0
Interview Prepcomputer-networksmediumGoogleAmazonFlipkartZepto

TCP Sequence Numbers, ACKs & Retransmission (RTO)

Choose your preparation mode3 modes available
🎯
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 sequence of server state changes when a client sends a PATCH request to update a user's email address. Which of the following best describes what happens step-by-step?
easy
A. The server modifies only the specified email field without affecting other user data.
B. The server replaces the entire user resource with the new email data.
C. The server creates a new user resource with the updated email.
D. The server deletes the old email and then inserts the new email as a separate resource.

Solution

  1. Step 1: Understand PATCH semantics

    PATCH is used for partial updates, modifying only specified fields.
  2. Step 2: Differentiate from PUT

    PUT replaces the entire resource, while PATCH updates parts.
  3. Step 3: Analyze options

    The server modifies only the specified email field without affecting other user data correctly states partial modification; others describe full replacement or resource creation/deletion.
  4. Final Answer:

    Option A -> Option A
  5. Quick Check:

    PATCH modifies only the targeted fields without affecting the rest.
Hint: PATCH = partial update, PUT = full replace
Common Mistakes:
  • Confusing PATCH with PUT and thinking it replaces the whole resource
  • Assuming PATCH creates new resources
  • Believing PATCH deletes and reinserts fields
2. In which OSI layer would you most likely implement encryption to secure data before transmission?
easy
A. Presentation Layer
B. Transport Layer
C. Application Layer
D. Network Layer

Solution

  1. Step 1: Understand the role of the Presentation Layer

    The Presentation Layer is responsible for data translation, encryption, and compression before passing data to the Session Layer.
  2. Step 2: Why not other layers?

    Application Layer handles user interface and application services, Transport Layer manages end-to-end communication and reliability, Network Layer handles routing and addressing but not encryption.
  3. Final Answer:

    Option A -> Option A
  4. Quick Check:

    Encryption is a Presentation Layer function [OK]
Hint: Encryption and data formatting happen at the Presentation Layer [OK]
Common Mistakes:
  • Assuming encryption is done at the Application Layer
  • Confusing Transport Layer's reliability with security
  • Thinking Network Layer handles encryption
3. In which scenario is WebSocket the most appropriate choice compared to HTTP Long Polling and Server-Sent Events (SSE)?
easy
A. When the application requires full-duplex communication with low latency and frequent bidirectional data exchange
B. When the client only needs to receive unidirectional real-time updates from the server with minimal overhead
C. When the server needs to push occasional updates but the client cannot maintain persistent connections
D. When the client wants to reduce server resource usage by opening a new HTTP request for each update

Solution

  1. Step 1: Analyze communication direction requirements

    WebSocket supports full-duplex communication, allowing simultaneous two-way data flow, unlike SSE and Long Polling which are unidirectional or half-duplex.
  2. Step 2: Consider latency and connection persistence

    WebSocket maintains a persistent connection with low latency, ideal for frequent bidirectional exchanges.
  3. Step 3: Evaluate other options

    When the client only needs to receive unidirectional real-time updates from the server with minimal overhead describes SSE, which is unidirectional from server to client. When the server needs to push occasional updates but the client cannot maintain persistent connections is inaccurate because SSE requires persistent connections. When the client wants to reduce server resource usage by opening a new HTTP request for each update describes naive Long Polling, which is resource-heavy.
  4. Final Answer:

    Option A -> Option A
  5. Quick Check:

    Full-duplex + low latency + frequent bidirectional data -> WebSocket
Hint: Full-duplex + frequent bidirectional updates -> WebSocket
Common Mistakes:
  • Confusing SSE as bidirectional
  • Assuming Long Polling is efficient for frequent updates
  • Believing WebSocket is only for server-to-client updates
4. Which of the following statements about the OSI Model is INCORRECT?
medium
A. The Data Link Layer is responsible for error detection and correction on the physical link.
B. The Network Layer is responsible for end-to-end reliable data delivery.
C. The Session Layer manages the establishment, maintenance, and termination of sessions.
D. The Physical Layer transmits raw bits over a physical medium.

Solution

  1. Step 1: Review Network Layer responsibilities

    The Network Layer handles routing and forwarding but does NOT guarantee reliable delivery.
  2. Step 2: Identify which layer ensures reliability

    Transport Layer provides end-to-end reliability, not Network Layer.
  3. Step 3: Validate other statements

    Data Link Layer handles error detection/correction on physical links, Session Layer manages sessions, Physical Layer transmits bits.
  4. Final Answer:

    Option B -> Option B
  5. Quick Check:

    Network Layer does NOT guarantee reliability [OK]
Hint: Reliability is Transport Layer's job, not Network Layer's [OK]
Common Mistakes:
  • Assuming Network Layer guarantees reliable delivery
  • Confusing Session Layer with Transport Layer
  • Misunderstanding Data Link Layer's error handling
5. Which of the following statements about WebSockets is INCORRECT?
medium
A. WebSocket communication is inherently secure and does not require additional encryption layers
B. WebSocket connections start as HTTP requests and then upgrade to a persistent full-duplex socket
C. WebSocket reduces latency by avoiding HTTP request-response overhead after connection establishment
D. WebSocket supports bidirectional communication allowing both client and server to send messages independently

Solution

  1. Step 1: Review WebSocket handshake

    WebSocket connections begin as HTTP requests and upgrade to a persistent socket (WebSocket connections start as HTTP requests and then upgrade to a persistent full-duplex socket is correct).
  2. Step 2: Consider security aspects

    WebSocket itself is a protocol and does not guarantee encryption; secure WebSocket (wss://) uses TLS for encryption. So, WebSocket communication is not inherently secure (WebSocket communication is inherently secure and does not require additional encryption layers is incorrect).
  3. Step 3: Analyze latency and communication

    WebSocket reduces latency by avoiding repeated HTTP overhead (WebSocket reduces latency by avoiding HTTP request-response overhead after connection establishment correct) and supports bidirectional communication (WebSocket supports bidirectional communication allowing both client and server to send messages independently correct).
  4. Final Answer:

    Option A -> Option A
  5. Quick Check:

    WebSocket requires TLS (wss://) for secure communication; it is not secure by default
Hint: WebSocket = HTTP upgrade + optional TLS for security
Common Mistakes:
  • Assuming WebSocket is always encrypted
  • Confusing WebSocket handshake with normal HTTP
  • Believing WebSocket is unidirectional
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