3

I have to implement a pseudo TCP handshake that leads into a file transfer. I have no problem doing the file transfer: simple send-acknowledge. What I can't wrap my head around is how to do the three way handshake assuming there will be packet loss during one of the 3 steps.

For instance: My client sends a SYN packet. If it times out (packet loss or just slow) waiting for SYN-ACK, it resends it. Server sends SYN-ACK. If it times out waiting for ACK, resend SYN-ACK. Now how does the client now that his ACK was received?

1 Answer 1

4

The client doesn't know that his ACK was received, but why does he care? The connection is established whether or not the ACK is received. You will never know for sure that the last packet sent was received, so you have to design a protocol that doesn't require that.

4
  • 1
    So why does the TCP protocol require it? Shouldn't the server be expecting it? If it doesn't receive the ACK because it was lost, it'll then receive a data packet. Won't it translate it incorrectly?
    – user111658
    Feb 23, 2012 at 5:14
  • 1
    It's the nature of the beast. If you require nothing at all, you don't have any protocol. And you have to tolerate some loss, or your protocol doesn't work. So it's a necessity that you will require some things that the protocol would work fine without. It's an unavoidable consequence of the two generals (or "last ack") problem. Feb 23, 2012 at 5:34
  • 6
    @user111658 If the server doesn't get the client's ACK, it'll resend its SYN/ACK (except if you have SYN cookies enabled, that is - which can implode the connection and freeze the client-side connection when the last ACK is lost in a server-talks-first protocol like SMTP). For your case, when the client's starting the data communication when it believes the connection to be up, its ACK to finalize the handshake is going to be in the header on the first data packet - to be resent if the server doesn't ACK it. Feb 23, 2012 at 6:02
  • 1
    @Shane, that should be an answer. Feb 23, 2012 at 8:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .