Why does TCP's three-way handshake bump the sequence number when acking?
Asked Answered
H

1

7

Why does the TCP three-way handshake bump the sequence number when acking during the initial handshake? How is that better than just leaving the acknowledgement number equal to the sequence number?

The connection is established with

Client sends SYN,A
Server responds with SYN-ACK,A+1,B
Client confirms with ACK,B+1

How is that better than

Client sends SYN,A
Server responds with SYN-ACK,A,B
Client confirms with ACK,B
Heterocyclic answered 24/7, 2011 at 4:42 Comment(1)
Z
5

That's because the ACK field means this when the ACK flag is set:

Acknowledgment number (32 bits) – if the ACK flag is set then the value of this field is the next sequence number that the receiver is expecting.

If it is not set to (inital sequence number+1), it would be inconsistently mean both ack'ing the SYN (both SYN and ACK flags must be set in this packet) and saying it is expecting that sequence number again (i.e. hasn't received it).

Zephaniah answered 24/7, 2011 at 5:0 Comment(6)
Sorry, I must be dense. I don't see the "inconsistency", hence my edits.Heterocyclic
ACK == n means "I have received all messages up to sequence number n-1 so please send me what you have for sequence number n". So that would be requesting a resend of the SYN from the client in your example which does not make any sens. Dealing with different sequence number semantics for the initial handshake would make the whole protocol more difficult to implement than it already is for no good reason.Zephaniah
I think what you're saying is that bumping the sequence number isn't actually necessary for the initial connection handshake, but bumping is needed for subsequent TCP ack-naks, so it's simply used all the time. I'll accept that as the answer.Heterocyclic
But subsequent TCP acknowledgements do not bump the sequence number! I even checked by running Wireshark. So I am still confused as to why the acknowlegdement number in the second and third steps of the handshake is 1 higher than the sequence numbers received in the first and second steps. For the duration of the handshake, no data is sent.Spacecraft
Once a TCP session is established, the sequence number only increases when a process is sending data. If the process is simply acknowledging data it received, the sequence number is the same in each acknowledgementSpacecraft
#2353024 has the answer, it is to acknowledge the SYN.Spacecraft

© 2022 - 2024 — McMap. All rights reserved.