Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

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.

share|improve this answer
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 '12 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. –  David Schwartz Feb 23 '12 at 5:34
5  
@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. –  Shane Madden Feb 23 '12 at 6:02
1  
@Shane, that should be an answer. –  Simon Richter Feb 23 '12 at 8:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.