TCP Sequence & Acknowledgment numbers

6,724
  • Yes, sequence number and acknowledgement number in packet 3 and 4 will indeed be identical.
  • No, the packets are not guaranteed to be exactly identical. Differences you might see include:
    • Packet 4 may also have the PSH flag set.
    • If timestamps are in use they could differ between 3 and 4.
    • The checksum will most likely be different.
  • The reason sequence number is the same in packet 3 and 4 is, that packet 3 did not contain any payload data.
  • The reason acknowledgement number is the same in packet 3 and 4 is, that no data was received from the server in the meantime.

Packet 3 is sort of redundant. The TCP layer could decide to wait a few microseconds before sending it and go straight to packet 4, if the application did write something to the socket during those microseconds.

I can recommend using Wireshark to inspect real traffic on your computer, that may help get an idea of what is going on.

Share:
6,724

Related videos on Youtube

Totem
Author by

Totem

Updated on September 18, 2022

Comments

  • Totem
    Totem almost 2 years

    I have looked through other questions on here involving the relevant topics, but I am still not clear on this.

    I have just been reading this explanation of TCP sequence & acknowledgment numbers. About half-way down there is this diagram:

    enter image description here

    Near the end of the page, the explanation of the final step, step 4, includes this text:

    Note that the sequence number of the segment in line 4 is the same as in line 3 because the ACK does not occupy sequence number space.

    So keep in mind that any packets generated, which are simply acknowledgments (in other words, have only the ACK flag set and contain no data) to previously received packets, never increment the sequence number.

    I am currently struggling to understand this:

    • I can clearly see that the sequence number in the packet sent in step 4 has the same sequence number as the packet sent in step 3.
    • It is also clear to see that the acknowledgement number is also the same in these steps
    • Basically, the author seems to be saying that the step 4 packet is identical to the step 3 packet, except that the step 4 packet contains data/payload.

    With regards to my first two points, is this correct?(as in has the author got it right?) With regards to my third point, is this correct? And finally, assuming the answer to the first two questions is basically 'yes', then is the reason that these numbers are the same in both packets because there hasn't been any intervening packet received from the Gateway server?

    I am seeking general clarification on this.

  • kasperd
    kasperd about 10 years
    An ACK is needed in order to let the server know, that the SYN-ACK was received. But there is no need to send the ACK twice, as it happens in the scenario you describe. However the network capacity saved by sending only one packet instead of packet 3 and 4 in the example, may not be enough to justify the additional complexity in the code needed, to figure out if the application is going to send something on the socket immediately. Until the ACK is sent, the application on the server will not be told about the connection, and the server may retransmit the SYN-ACK packet.