Practice
Solution
Step 1: Identify the purpose of the handshake
The TCP three-way handshake is designed to establish a reliable, connection-oriented session between two hosts before data transfer.Step 2: Analyze each option
Sending a single UDP datagram to a remote host is incorrect because UDP is connectionless and does not use a handshake. Broadcasting a message to multiple hosts on a local network is incorrect because broadcasting does not require connection establishment. Encrypting data packets for secure transmission is unrelated to connection setup; encryption is a separate process.Final Answer:
Option B -> Option BQuick Check:
Only TCP connections require this handshake to ensure reliability and synchronization.
- Confusing TCP handshake with UDP communication
- Assuming handshake is needed for broadcast or encryption
Solution
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.Step 2: Consider latency and connection persistence
WebSocket maintains a persistent connection with low latency, ideal for frequent bidirectional exchanges.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.Final Answer:
Option A -> Option AQuick Check:
Full-duplex + low latency + frequent bidirectional data -> WebSocket
- Confusing SSE as bidirectional
- Assuming Long Polling is efficient for frequent updates
- Believing WebSocket is only for server-to-client updates
Solution
Step 1: Review ACK number behavior
ACK numbers are cumulative and indicate the next byte expected, acknowledging all prior bytes.Step 2: Analyze duplicate ACKs
Duplicate ACKs often indicate packet loss but can also occur due to reordering; immediate retransmission is triggered only after three duplicates (fast retransmit).Step 3: Evaluate options
TCP acknowledgment numbers are cumulative and indicate the next expected byte from the sender is correct. Duplicate ACKs always indicate packet loss and require immediate retransmission is incorrect because duplicate ACKs do not always require immediate retransmission. An ACK number can acknowledge multiple segments if they are received in order is correct as ACK numbers can acknowledge multiple segments. ACK numbers help the sender detect which data has been successfully received is correct.Final Answer:
Option B -> Option BQuick Check:
Duplicate ACKs signal potential loss but do not always trigger immediate retransmission.
- Assuming every duplicate ACK means packet loss
- Confusing cumulative ACKs with selective ACKs
- Believing ACK numbers acknowledge individual segments only
Solution
Step 1: Understand rate limiting status codes
429 Too Many Requests is the standard status code for rate limiting.Step 2: Importance of Retry-After header
Including Retry-After tells the client when to retry, enabling graceful handling.Step 3: Analyze options
Return a 429 status code with a Retry-After header indicating when the client can retry. is correct: 429 + Retry-After is best practice.
Return a 403 status code without any additional headers to block the client permanently. is incorrect: 403 forbids access but does not indicate rate limiting or retry timing.
Return a 500 status code to indicate the server is overloaded and cannot process requests. is incorrect: 500 indicates server error, not client rate limiting.
Return a 200 status code with an error message in the response body. is incorrect: 200 means success, which misleads clients about request status.Final Answer:
Option C -> Option CQuick Check:
Use 429 with Retry-After for rate limiting to communicate clearly with clients.
- Using 403 or 500 instead of 429 for rate limiting
- Omitting Retry-After header causing client confusion
- Returning 200 with error message, breaking client logic
Solution
Step 1: Understand header stacking impact
Stacking all headers into one large header increases packet overhead, reducing effective throughput.Step 2: Why other options are incorrect
Visibility of headers does not inherently improve security; encryption is separate. No impact on performance is false. Reduced latency is unlikely due to larger packet size.Step 3: How to address the issue
Optimizing header sizes and applying header compression reduces overhead and improves efficiency.Final Answer:
Option D -> Option DQuick Check:
Large headers increase overhead and reduce throughput [OK]
- Assuming large headers improve security automatically
- Ignoring performance impact of large headers
- Believing latency always decreases with header stacking
