The three-way handshake — Aptitude Question
The three-way handshake: What is the correct order of segments in the TCP three-way handshake? Answer and worked solution on CodeKairo.
- Topic: OS, DBMS & Networks
- Section: Programming MCQs
- Difficulty: Easy
- Time target: 45 seconds
Question
What is the correct order of segments in the TCP three-way handshake?
Options
- ACK, SYN, SYN-ACK
- SYN, ACK, SYN-ACK
- SYN, SYN-ACK, ACK
- SYN-ACK, SYN, ACK
Show the answer and the worked solution
Correct answer: C. SYN, SYN-ACK, ACK
Worked solution
- The client opens by sending a SYN carrying its initial sequence number.
- The server replies with a single segment that both acknowledges the client's SYN and carries its own SYN — the SYN-ACK.
- The client acknowledges the server's SYN with an ACK, and the connection is open: SYN, SYN-ACK, ACK.
Answer: SYN, SYN-ACK, ACK.
The idea
Each side must announce a sequence number and have it acknowledged, which would take four segments; combining the server's SYN with its ACK is what reduces it to three.
Shortcut. Nothing can be acknowledged before it is sent, so SYN must come first and a bare ACK last, and only SYN, SYN-ACK, ACK fits.
Common trap. "SYN, ACK, SYN-ACK" starts correctly, but the server does not acknowledge first and send its own SYN separately; one SYN-ACK does both.