💡 TCP connections begin with a SYN packet to synchronize sequence numbers.
setup
Server receives SYN and replies with SYN-ACK
The server receives the SYN, processes it, and replies with a SYN-ACK packet. The server's sequence number is 3000, and it acknowledges the client's SYN by setting ACK=1001.
💡 The server acknowledges the client's SYN and sends its own SYN to synchronize sequence numbers both ways.
💡 Sequence numbers track the byte offset of data sent for reliable delivery.
compare
Server receives data and sends ACK (ack=1006)
The server receives the data packet with seq=1001 and payload 'Hello' (5 bytes). It sends an ACK with ack=1006, indicating it expects the next byte at 1006.
💡 ACK numbers confirm receipt of data and indicate the next expected byte.
💡 Sequence numbers ensure data ordering and tracking of bytes sent.
prune
Second data packet lost in transit (no ACK received)
The second data packet is lost and does not reach the server. The client waits for an acknowledgment but none arrives before the retransmission timeout (RTO).
💡 Packet loss triggers retransmission mechanisms in TCP to ensure reliability.
Line:# Packet lost, no ACK received; wait for RTO
💡 TCP detects lost packets by missing ACKs and uses timers to trigger retransmission.
retransmit
Retransmission timeout (RTO) triggers resend of lost packet
The client's retransmission timer expires (RTO). It resends the lost data packet with seq=1006 and payload 'World'.
💡 Retransmission ensures lost data is resent to maintain reliable delivery.
💡 TCP uses timers to detect lost packets and trigger retransmission automatically.
compare
Server receives retransmitted packet and sends ACK (ack=1011)
The server receives the retransmitted packet with seq=1006 and payload 'World'. It sends an ACK with ack=1011, confirming receipt of all data up to byte 1010.
💡 ACK confirms cumulative receipt of data, including retransmitted packets.
Client receives final ACK confirming all data received
The client receives the ACK with ack=1011, confirming all sent data has been received by the server. The connection is now fully synchronized and data transfer is complete.
💡 Final ACK confirms reliable delivery of all data and allows the client to send more data or close connection.
Line:# Client processes final ACK
💡 TCP uses ACKs to confirm data delivery and maintain flow control.
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)
✓ 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. When a link failure occurs in a network running Distance Vector routing, what sequence of events typically happens before all routers have updated their routing tables?
easy
A. Routers immediately flood the network with link state advertisements, then recompute shortest paths
B. Routers notify neighbors of the failure, update their tables, and neighbors propagate updates iteratively until convergence
C. Routers wait for a periodic timer to expire before sending updates, causing immediate global convergence
D. Routers use a centralized controller to recompute routes and push updates to all routers
Solution
Step 1: Identify Distance Vector update mechanism
Distance Vector routers share routing information only with neighbors and rely on iterative updates.
Step 2: Trace the failure propagation
When a link fails, a router detects it and updates its routing table, then sends updates to neighbors. Neighbors update their tables and propagate changes further, iteratively converging.
Step 3: Analyze options
Routers immediately flood the network with link state advertisements, then recompute shortest paths describes Link State behavior, not Distance Vector. Routers wait for a periodic timer to expire before sending updates, causing immediate global convergence is incorrect because updates are sent immediately upon detecting changes, not only on timers, and convergence is not immediate. Routers use a centralized controller to recompute routes and push updates to all routers is incorrect because Distance Vector is decentralized.
Final Answer:
Option B -> Option B
Quick Check:
Distance Vector uses neighbor-to-neighbor iterative updates after failure detection.
Hint: Distance Vector updates propagate hop-by-hop, not flooded globally
Common Mistakes:
Confusing Distance Vector with Link State flooding
Assuming immediate global updates without iteration
Thinking Distance Vector uses centralized control
2. Which of the following statements about HTTP 4xx and 5xx status codes is INCORRECT?
medium
A. 4xx status codes indicate client-side errors, meaning the client must modify the request to succeed.
B. 5xx status codes indicate server-side errors, meaning the server failed to fulfill a valid request.
C. A 403 status code means the client is forbidden from accessing the resource, even if authenticated.
D. A 404 status code means the server is temporarily unavailable and the client should retry later.
Solution
Step 1: Review meanings of 4xx and 5xx status codes
4xx = client errors; 5xx = server errors.
Step 2: Analyze each statement
4xx status codes indicate client-side errors, meaning the client must modify the request to succeed. is correct: 4xx means client must fix request. 5xx status codes indicate server-side errors, meaning the server failed to fulfill a valid request. is correct: 5xx means server failed. A 404 status code means the server is temporarily unavailable and the client should retry later. is incorrect: 404 means 'Not Found', not temporary unavailability; 503 indicates temporary server unavailability. A 403 status code means the client is forbidden from accessing the resource, even if authenticated. is correct: 403 means forbidden access regardless of authentication.
Final Answer:
Option D -> Option D
Quick Check:
404 is about missing resource, not server availability.
Hint: 404 = Not Found, 503 = Service Unavailable
Common Mistakes:
Confusing 404 with temporary server errors
Assuming 403 means unauthenticated rather than forbidden
Mixing client and server error categories
3. 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
Step 1: Identify real-time game requirements
Low latency and timely updates are critical; some packet loss is tolerable.
Step 2: Analyze TCP behavior
TCP ensures reliability and ordered delivery by retransmitting lost packets, which adds latency.
Step 3: Analyze UDP behavior
UDP sends packets without retransmission or ordering, reducing delay.
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.
Final Answer:
Option D -> Option D
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
4. Which of the following statements about UDP is INCORRECT?
medium
A. UDP provides built-in congestion control to avoid network overload
B. UDP is connectionless and does not guarantee packet delivery
C. UDP is suitable for applications where speed is more important than reliability
D. UDP packets may arrive out of order or be duplicated
Solution
Step 1: Review UDP characteristics
UDP is connectionless, unreliable, and does not guarantee delivery or order.
Step 2: Analyze congestion control
UDP does not implement congestion control; it sends packets without adjusting to network conditions.
Step 3: Evaluate options
UDP provides built-in congestion control to avoid network overload is incorrect because UDP lacks congestion control. Options A, C, and D correctly describe UDP behavior.
Final Answer:
Option A -> Option A
Quick Check:
UDP is simple and fast but does not manage congestion.
Hint: UDP = no connection, no reliability, no congestion control.
Common Mistakes:
Assuming UDP has congestion control like TCP
Believing UDP guarantees packet order
Confusing connectionless with unreliable
5. If a domain's authoritative DNS server is down, which of the following best describes how DNS resolution behaves assuming the recursive resolver has a cached entry with a TTL of 300 seconds that expired 10 seconds ago?
hard
A. The recursive resolver will attempt to query the authoritative server despite the expired TTL and return an error if unreachable.
B. The recursive resolver will return the expired cached record to the client to avoid resolution failure.
C. The recursive resolver will immediately return a SERVFAIL error to the client since the authoritative server is unreachable.
D. The recursive resolver will query the root server again to find an alternative authoritative server.
Solution
Step 1: Understand TTL expiration
Once TTL expires, cached records are considered stale and should not be served without validation.
Step 2: Behavior on authoritative server failure
The recursive resolver tries to refresh the record by querying the authoritative server.
Step 3: Outcome if authoritative server is down
If unreachable, the resolver returns an error (e.g., SERVFAIL) to the client.
Step 4: Why other options are incorrect
The recursive resolver will immediately return a SERVFAIL error to the client since the authoritative server is unreachable ignores retry attempt; The recursive resolver will return the expired cached record to the client to avoid resolution failure violates TTL rules by serving expired data; The recursive resolver will query the root server again to find an alternative authoritative server is incorrect because root servers do not provide alternative authoritative servers.