- The sequence number identifies the byte in the stream of data from the sending TCP to the receiving TCP that the first byte of data in this segment represents.
- The Acknowledgement number field contains the next sequence number that the sender of the acknowledgement expects to receive. This is therefore the sequence number plus 1 of the last successfully received byte of data. This field is valid only if the ACK flag is on. Once a connection is established the Ack flag is always on.
- The Acknowledgement, SequenceNum, and AdvertisedWindow fields are all involved in TCP's sliding window algorithm.The Acknowledgement and AdvertisedW indow fields carry information about the flow of dat going in the other direction. In TCP's sliding window algorithm the reciever advertises a window size to the sender. This is done using the AdvertisedWindow field. The sender is then limited to having no more than a value of AdvertisedWindow bytes of un acknowledged data at any given time. The receiver sets a suitable value for the AdvertisedWindow based on the amount of memory allocated to the connection for the purpose of buffering data.
- see picture at
- source: http://www.ssfnet.org/Exchange/tcp/tcpTutorialNotes.html
So, let me check if I get it . Suppose for example a fixed window of 100 bytes and 500 as a starting sequence number. After succesfully receiving three segments with sequence numbers 500, 600 and 700, the receiver sends an acknowledgement with the number 800 (because last byte received is 799).
Is this right?
Suppose the sender sends 500 600 700 800 and 900, and segment with sequence number 700 is lost. So, the receiver receives only 500 600 800 and 900 and sends an acknowledgment of 700 (which is the next segment it expects to receive). After that, sender re-sends segment 700.
I think there is no doubt up to this point, correct me if I'm wrong.
The doubt here is what happens with segments 800 and 900. I think that when the receiver receives segment 700, because he also has 800 and 900, he sends an acknowledgement of 1000.
I'm not sure if this is the case, or if the receiver sends an acknowledgement of 800.
Thanks in advance!
That is a great question. There are a couple of points. In the first part, you said there was a fixed window of 100. In your example, you said the sender sends 500, 600, 700, 800 and 900. The issue was that the receiver did not get 700. Therefore this is an impossibility. The sender would have needed an acknowledgement to advance the window and send segment 800.
Let's rework the question a bit. Let's imagine that the window is something large, 65535 for example. Now the receiver did not receive "700". In this case, the receiver would start sending duplicate acknowledgements with ack number "700". This would happen until segment 700 was received. In this case, the receiver has already received 800 and 900 and each have a length of 100 octets. So it would generate an ack with number 1000.
There are some interesting other topic like fast and slow retransmit and selective acks that you can dig into. I really recommend Laura Chappells book to everyone.
Thanks Paul for your answer.
I understand a bit more now. I think I'm closer .
I'm a bit confused with the "window" term. As I understand, is the ammount of bytes the sender has to be acknowledged before sending more data.
Then, how do you call the difference between 500, 600, ... , 1000 (100 bytes) ? Is there a name for that?
Wireshark simply calls it length. That is the number of octets or bytes that are in the TCP Data portion of the packet (or more accurately the segment). So in your example, the tcp length is 100 (bytes or octets). The field doesn't really exist in the header, but that is the representation. This is not the windows size. The window size is exactly as you said. The number of bytes or octets that can be sent unacknowledged. There are some other things that come into play with TCP to keep it working, so ack's usually happen more often than the max window size. In practice, there is usually an ack for each two segments sent. Back to the "100". This length has a maximum of the mss (maximum segment size). This is determined to be the lowest of the mss sent in the options during setup and is least value of the initiator and responder. HTH.