Bird
Raised Fist0
Interview Prepcomputer-networksmediumGoogleAmazonFlipkartZepto

TCP Sequence Numbers, ACKs & Retransmission (RTO)

Choose your preparation mode3 modes available
▶
Steps
setup

Client sends SYN to initiate connection

The client sends a SYN packet to the server to start the TCP three-way handshake. This packet has an initial sequence number (seq=1000).

💡 This step establishes the start of a TCP connection and sets the initial sequence number for tracking data.
Line:send_packet(src='client', dst='server', seq=1000, flags=['SYN'])
💡 TCP connections begin with a SYN packet to synchronize sequence numbers.
📊
TCP Sequence Numbers, ACKs & Retransmission (RTO) - Watch the Algorithm Execute, Step by Step
Watching this step-by-step visualization helps you understand how TCP manages sequence numbers and acknowledgments to guarantee data delivery, and how retransmission works when packets are lost or delayed.
Step 1/10
·Active fill★Answer cell
Client sends SYN to initiate connection and set initial sequence number
Hop: 1
Client
Server
📦Packet
↗ fromclient
↘ toserver
🔌 protocolTCP
🚩 flagsSYN
src→10.0.0.1:50000
dst→10.0.0.2:80
flags→SYN
SYN: client→server (seq=1000)
Server replies with SYN-ACK to acknowledge client's SYN and send its own sequence number
Hop: 2
Client
Server
📦Packet
↗ fromserver
↘ toclient
🔌 protocolTCP
🚩 flagsSYN, ACK
src→10.0.0.2:80
dst→10.0.0.1:50000
flags→SYN, ACK
SYN: client→server (seq=1000)
SYN-ACK: server→client (seq=3000, ack=1001)
Client sends ACK to complete handshake and confirm server's sequence number
Hop: 3
Client
Server
📦Packet
↗ fromclient
↘ toserver
🔌 protocolTCP
🚩 flagsACK
src→10.0.0.1:50000
dst→10.0.0.2:80
flags→ACK
SYN: client→server (seq=1000)
SYN-ACK: server→client (seq=3000, ack=1001)
ACK: client→server (seq=1001, ack=3001)
Client sends first data packet with sequence number 1001
Hop: 4
Client
Server
📦Packet
↗ fromclient
↘ toserver
📄 payloadHello
🔌 protocolTCP
🚩 flags
src→10.0.0.1:50000
dst→10.0.0.2:80
data→Hello
SYN-ACK: server→client (seq=3000, ack=1001)
ACK: client→server (seq=1001, ack=3001)
DATA: client→server (seq=1001, data='Hello')
Server acknowledges receipt of 5 bytes, expecting next byte 1006
Hop: 5
Client
Server
📦Packet
↗ fromserver
↘ toclient
🔌 protocolTCP
🚩 flagsACK
src→10.0.0.2:80
dst→10.0.0.1:50000
flags→ACK
ACK: client→server (seq=1001, ack=3001)
DATA: client→server (seq=1001, data='Hello')
ACK: server→client (seq=3001, ack=1006)
Client sends second data packet with sequence number 1006
Hop: 6
Client
Server
📦Packet
↗ fromclient
↘ toserver
📄 payloadWorld
🔌 protocolTCP
🚩 flags
src→10.0.0.1:50000
dst→10.0.0.2:80
data→World
DATA: client→server (seq=1001, data='Hello')
ACK: server→client (seq=3001, ack=1006)
DATA: client→server (seq=1006, data='World')
Second data packet lost; client waits for ACK but none arrives
Hop: 7
Client
Server
ACK: server→client (seq=3001, ack=1006)
DATA: client→server (seq=1006, data='World')
Packet lost: DATA seq=1006
Client retransmits lost packet after timeout (RTO)
Hop: 8
Client
Server
📦Packet
↗ fromclient
↘ toserver
📄 payloadWorld
🔌 protocolTCP
🚩 flagsRTO
src→10.0.0.1:50000
dst→10.0.0.2:80
data→World
flags→RTO
DATA: client→server (seq=1006, data='World')
Packet lost: DATA seq=1006
RTO Retransmit: client→server (seq=1006, data='World')
Server acknowledges receipt of retransmitted data up to byte 1010
Hop: 9
Client
Server
📦Packet
↗ fromserver
↘ toclient
🔌 protocolTCP
🚩 flagsACK
src→10.0.0.2:80
dst→10.0.0.1:50000
flags→ACK
Packet lost: DATA seq=1006
RTO Retransmit: client→server (seq=1006, data='World')
ACK: server→client (seq=3001, ack=1011)
Client receives final ACK confirming all data received
Hop: 10
Client
Server
📦Packet
↗ fromserver
↘ toclient
🔌 protocolTCP
🚩 flagsACK
src→10.0.0.1:50000
dst→10.0.0.2:80
flags→ACK
RTO Retransmit: client→server (seq=1006, data='World')
ACK: server→client (seq=3001, ack=1011)
ACK received: client confirms all data received

Key Takeaways

✓ TCP uses sequence numbers and ACKs to track data sent and received, ensuring reliable delivery.

This insight is hard to see from code alone because sequence and ACK numbers are abstract counters; visualization shows their flow and updates clearly.

✓ Retransmission timeout (RTO) triggers resending lost packets automatically to recover from packet loss.

Plain English explanation: when an ACK is not received in time, TCP resends the missing data to guarantee delivery.

✓ The three-way handshake synchronizes sequence numbers between client and server before data transfer begins.

Seeing the SYN, SYN-ACK, and ACK packets in sequence clarifies how TCP establishes connection state.

Practice

(1/5)
1. Trace the sequence of DNS queries when a browser requests 'www.example.com' and the local DNS cache is empty. Which of the following correctly describes the order of servers queried?
easy
A. Local resolver -> Recursive DNS server -> Root DNS server -> TLD DNS server -> Authoritative DNS server
B. Local resolver -> TLD DNS server -> Root DNS server -> Recursive DNS server -> Authoritative DNS server
C. Local resolver -> Root DNS server -> Recursive DNS server -> TLD DNS server -> Authoritative DNS server
D. Local resolver -> Recursive DNS server -> Authoritative DNS server -> Root DNS server -> TLD DNS server

Solution

  1. Step 1: Start at local resolver

    The browser asks the local resolver, which forwards to the recursive DNS server if cache is empty.
  2. Step 2: Recursive DNS server queries root server

    The recursive server queries the root DNS server to find the TLD server for '.com'.
  3. Step 3: Recursive server queries TLD server

    Root server directs to TLD server, which is then queried for 'example.com'.
  4. Step 4: Recursive server queries authoritative server

    TLD server directs to authoritative DNS server for 'example.com', which returns the IP.
  5. Final Answer:

    Option A -> Option A
  6. Quick Check:

    Order matches DNS resolution hierarchy and recursive query flow -> correct
Hint: Recursive DNS server queries root -> TLD -> authoritative servers in order.
Common Mistakes:
  • Misplacing root server query after authoritative server
  • Confusing order of recursive and root server queries
  • Assuming local resolver queries root server directly
2. You need to design a RESTful API endpoint that retrieves user profile information without modifying any server data. Which HTTP method should you use to ensure the operation is safe and does not change server state?
easy
A. GET
B. POST
C. PUT
D. DELETE

Solution

  1. Step 1: Understand the safety property of HTTP methods

    GET is defined as a safe method, meaning it does not modify server state and is used to retrieve data.
  2. Step 2: Analyze other methods

    POST, PUT, and DELETE modify server state and are not safe methods.
  3. Final Answer:

    Option A -> Option A
  4. Quick Check:

    GET is the only safe method here, suitable for data retrieval without side effects.
Hint: GET = safe read, POST/PUT/DELETE = state change
Common Mistakes:
  • Confusing POST with GET as both can send data
  • Thinking PUT is safe because it replaces data
  • Assuming DELETE can be used to retrieve data
3. Trace the process of determining the network and host portions of the IP address 192.168.10.25 with subnet mask 255.255.255.240. What is the network address?
easy
A. 192.168.10.240
B. 192.168.10.0
C. 192.168.10.25
D. 192.168.10.16

Solution

  1. Step 1: Convert subnet mask to binary

    255.255.255.240 = 11111111.11111111.11111111.11110000
  2. Step 2: Convert IP address to binary

    192.168.10.25 = 11000000.10101000.00001010.00011001
  3. Step 3: Perform bitwise AND between IP and subnet mask

    Result = 11000000.10101000.00001010.00010000 = 192.168.10.16
  4. Step 4: Interpret result

    The network address is 192.168.10.16, which identifies the subnet.
  5. Final Answer:

    Option D -> Option D
  6. Quick Check:

    Subnet mask 255.255.255.240 divides the last octet into 16-address blocks; 25 falls into 16-31 range [OK]
Hint: Network address = IP AND subnet mask
Common Mistakes:
  • Using the IP address itself as the network address
  • Using the subnet mask as the network address
  • Assuming the network address is always .0
4. Trace the sequence of layers a data packet passes through when a user sends an email using SMTP over TCP/IP. Which order correctly represents the encapsulation process from the sender's perspective?
easy
A. Application -> Transport -> Internet -> Network Interface
B. Network Interface -> Internet -> Transport -> Application
C. Internet -> Transport -> Application -> Network Interface
D. Transport -> Application -> Internet -> Network Interface

Solution

  1. Step 1: Understand encapsulation order in TCP/IP model

    Data starts at the Application Layer (SMTP), then is passed down to Transport Layer (TCP) for segmentation and connection management, then to Internet Layer (IP) for routing, and finally to Network Interface Layer for physical transmission.
  2. Final Answer:

    Option A -> Option A
  3. Quick Check:

    Encapsulation order is top-down: Application -> Transport -> Internet -> Network Interface [OK]
Hint: Encapsulation flows top-down from Application to Network Interface
Common Mistakes:
  • Confusing encapsulation with decapsulation order
  • Mixing up Internet and Transport layers
  • Assuming Network Interface is the first layer
5. Why might using TCP for a real-time multiplayer game cause performance issues compared to UDP?
medium
A. TCP packets are always larger than UDP packets, increasing bandwidth usage
B. TCP does not support packet loss detection, causing inconsistent game state
C. UDP requires establishing a connection first, which delays game startup
D. TCP's retransmission and ordering guarantees introduce latency that can disrupt real-time responsiveness

Solution

  1. Step 1: Identify real-time game requirements

    Low latency and timely updates are critical; some packet loss is tolerable.
  2. Step 2: Analyze TCP behavior

    TCP ensures reliability and ordered delivery by retransmitting lost packets, which adds latency.
  3. Step 3: Analyze UDP behavior

    UDP sends packets without retransmission or ordering, reducing delay.
  4. Step 4: Evaluate options

    TCP's retransmission and ordering guarantees introduce latency that can disrupt real-time responsiveness correctly explains TCP's latency impact. TCP does detect packet loss, so TCP does not support packet loss detection, causing inconsistent game state is incorrect. UDP is connectionless, so UDP requires establishing a connection first, which delays game startup is incorrect. Packet size depends on payload, so TCP packets are always larger than UDP packets, increasing bandwidth usage is incorrect.
  5. Final Answer:

    Option D -> Option D
  6. Quick Check:

    TCP's reliability mechanisms add latency unsuitable for real-time games.
Hint: TCP = reliable but slower; UDP = faster but less reliable.
Common Mistakes:
  • Believing TCP does not detect packet loss
  • Thinking UDP requires connection setup
  • Assuming TCP packets are always larger
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