So guys, now let us discuss the sequence number and acknowledgement number and where the sequence number
and acknowledgement number reside in a standard TCP header.
So this is the image which shows the diagram of a standard TCP header format.
So this diagram splits the TCP header into five rows and each row is of size four bytes.
Right.
So we have five rows here.
So you can see that in the first row we have source port number and destination port number.
Now what are these?
Suppose you have a sending machine as and you have a receiving machine are on sending machine.
You are running an application a which is listening on TCP port number 80 and on receiving machine.
You are running an application B which is listening say on TCP port number 40.
Right?
So for all the TCP segments, which are going from the sending machine s to the recipient machine are
the source port number will be 80 and the destination port number will be 40.
Right.
And for all the TCP segments which are coming from machine R to machine S, the source port number will
be opposite.
That is the source.
Port number will be 40 and the destination port number will be 80.
Then in the second row we have a sequence number which is 32 bit number.
And after that, in the third row, we have an acknowledgement number.
So for any TCP segment going from S to R or coming from R to S, there will always be a valid sequence
number.
Every TCP segment has to have a sequence number, whereas acknowledgement number is optional.
If the TCP segment is being used to acknowledge the TCP data, then that particular TCP segment will
contain an acknowledgement number.
Otherwise, if the TCP segment contains only application data and it is not being used as an Ack segment,
then in that particular segment the acknowledgement number value is invalid or meaningless.
We will describe the various types of TCP segments in the next lecture video.
And there we will see that in what TCP segment the acknowledgement number is meaningful and in what
TCP segment, the acknowledgment number is not meaningful.
So in a TCP segment we have a special bit called ack bit, right?
If this bit is set, it means that the acknowledgement number is specified is meaningful acknowledgement
number.
If a bit is not set, then TCP protocol.
Do not even bother to read this acknowledgement number.
Right.
So bit act as a flag for the validity of acknowledgement number.
Then there are other fields like window size, urgent pointer checksum, but their discussion is not
worth at this point of time.
As we progress into this course, we will discuss the use of the remaining fields of this TCP header.
So sequence number field is mandatory and is always present in a TCP segment, irrespective of the segment
type.
Now you must be wondering what are the different types of segments which TCP supports?
So wait for the next lecture video.
We will discuss the various type of segments which TCP protocol supports and acknowledgment number is
valid only when bit is set.
So going forward, let us discuss about the sequence number.
We already have enough discussion about the sequence number.
So sequence number is like a unique identifier of the segment in TCP.
Every byte has a sequence number and not every segment.
In fact, the segment number is nothing, but it is a sequence number of first byte of data present
in a segment sequence.
Number of first byte of application data in payload of a segment is termed as sequence number of a segment.
So we interchangeably use sequence number as segment number for a segment in this course.
So you can see in this example, suppose we have a segment whose sequence number is 1000, right?
So in the TCP header, we already have seen that there is a field called sequence number and the value
of that particular field will be set to 1000.
And after TCP header, we have application data whose size is 500 bytes, right?
So as I said, every byte has a sequence number.
So if we imagine the application data as sequence of bytes packed one after the another, then the sequence
number of the first byte of application data will be 1000, right?
And the sequence number of the last byte of the application data present in this segment will be 1499.
Right.
It means that the sequence number of the first byte of application data present in the very next segment
generated by the TCP sender will be 1500.
Right.
So that is why this segment has a sequence number 1500.
Right.
So sequence number is incremented by TCP sender by the amount of bytes the sender has sent in the previous
segment.
Right.
So you can see that the sequence number of this segment is 1000.
And because it has shaped 500 bytes of application data, therefore sequence number of the next segment
generated by the TCP will be 1500 then discussing the acknowledgement number.
Acknowledgement number is the sequence number of the segment which the TCP receiver expects from the
TCP sender in the next segment.
Right.
So note that acknowledgment number is the expectation of the TCP receiver.
In other words, if TCP receiver specify an acknowledgement number, for example, 2000 with a bit set
in the segment.
Now, we already discussed that there is a bit called a bit in a TCP header and only if this bit is
set then acknowledgement number is meaningful.
So when the TCP receiver generates a segment and in that particular segment, the TCP receiver sets
the Ack bit and specify the acknowledgement number as 2000.
It simply means that TCP receiver is telling the TCP sender that, Hey, I have successfully received
your 1999 bytes of data and I am expecting 2,000th byte of data and onwards.
Now in your next segment, right?
So always remember the acknowledgement is the expectation of the TCP receiver acknowledgement bit combined
with acknowledgement number is a feedback to the TCP sender from the TCP receiver about the confirmation
of successful reception of TCP payload data.
Right.
Then comes the concept of TCP piggybacks.
It means that in the same segment, the TCP sender can ship the payload bytes.
That is the application data specifying a new sequence number.
Now, because TCP sender is shipping new fresh bytes of application data, it means that the sequence
number of very first byte of the application data packet in this segment will be new sequence number.
And TCP sender at the same time acknowledges the previous TCP data it has received from peer using acknowledgment
number and acknowledgement bit.
So you can see that in the same segment the TCP sender is performing two tasks.
It is sending application data as well as it is acknowledging the previous TCP data it has received
from the other side.
So I understand there is a need of example to understand this.
So let us understand this piggybacking and various type of TCP segments in the next lecture video.