Search code examples
tcpnetwork-programming

How TCP handle packet loss during three-way handshake?


When establishing a connection, TCP uses three-way handshake.

step 1: client send SYN to server
step 2: server send SYN/ACK to client
step 3: client send ACK to server

But, in step 1, 2 or 3, packet may be lost.
I have 3 questions, please help me on that.

  1. How TCP handle packet loss during three-way handshake ?
  2. Is there any ways to simulate the packet loss issues ?
  3. TCP handle the problem automatically or developer must also handle it ?

Thanks for any advice.


Solution

  • How TCP handle packet loss during three-way handshake ?

    Retransmission, as with any other kind of packet loss. That's why you have ACK's in the handshake.

    Is there any ways to simulate the packet loss issues ?

    Sure but it depends on your knowledge. For example in Linux in iptables (firewall) rule could be created which drops some but not all SYN packets. See also Simulate delayed and dropped packets on Linux.

    TCP handle the problem automatically or developer must also handle it ?

    This is transparent to the developer. At most the applications gets a connection failure (timeout).