Q: What is the three-way handshake and four-way wave? Why does TCP need a three-way handshake?
A: The three-way handshake is the process TCP uses to establish a connection:
- The client sends a
SYNpacket to the server to initiate the connection. - The server responds with a
SYN-ACKpacket to acknowledge the request and agree to the connection. - The client sends an
ACKpacket to confirm the connection is established.
The four-way wave is the process TCP uses to terminate a connection:
- The client sends a
FINpacket to the server to request connection closure. - The server responds with an
ACKpacket to acknowledge the request. - The server then sends its own
FINpacket to the client to indicate it also wants to close the connection. - The client sends an
ACKpacket to confirm the connection is fully closed.
Why does TCP need a three-way handshake? The three-way handshake is essential to establish a reliable connection. It ensures that both the client and server are ready to send and receive data and allows them to synchronise their initial sequence numbers. This synchronisation is the foundation for the reliable, ordered data transfer that TCP provides.