So, guys, now continuing our discussion with respect to segments and sequence numbers.
So what exactly sequence number is?
Sequence number is the unique ID of a byte of data which TCP sender sends to a receiver.
Right.
So every byte of data which is provided by the application running in the application layer to the underlying
TCP protocol, which is running in the transport layer, is assigned incremental sequence number by
TCP.
So sequence number of first byte of application data present in a segment is also referred to as segment
number.
So let us try to understand these points with the help of an example.
So suppose you have a sending process which is running in the application layer.
And suppose this sending process generates some application data and this application data is handed
over to the underlying TCP protocol, which is running in the transport layer.
Now, as soon as the TCP protocol receives the data from the sending process, the TCP protocol generates
segments.
The TCP protocol packages, the application data into segments.
So for example, suppose the sending TCP create a segment whose segment number is 500.
Now 500.
We have chosen it randomly.
Now, let us suppose that the size of this segment is 100 bytes, right?
So the sequence number of first byte of application data present in this segment will be 500.
And since this segment contains 100 bytes, therefore.
The range of sequence number which is assigned to all the bytes which is present in this particular
segment will be from 500 to 599, because the amount of application data present in this segment is
100 bytes.
This is what we have assumed.
Now, suppose the sending process keeps on feeding more data to the sending TCP, right?
So sending TCP will create more segments.
Now, since the sequence number until 599 have already been used, therefore the sequence number, which
is assigned to the first byte of application data present in this second segment will be 600.
And again, we assume that the size of this segment is 100 bytes.
Therefore, range of sequence number, which is assigned to the application bytes present in this segment
will be from 600 to 699.
Right.
Similarly, TCP will keep on creating segments with incremental sequence number.
Remember, the segment number is the sequence number of the first byte of application data present in
a segment.
So segment number of this segment is 700.
And the segment number of this segment is 800.
Going forward.
Every byte of data is identified by sequence number so that TCP can keep track of each byte, whether
that particular byte has been reliably delivered to the receiver or not.
Right.
So this is the purpose of sequence number.
So sequence number is like an identity of each byte of application data which sending TCP is sending
to the receiving TCP going forward.
TCP do not examine what data application is sending to it and how it is structured from TCP perspective.
All application data is just zeros or ones or in other words, it is nothing but junk.
TCP has no business to understand what application data is from TCP perspective.
The application data is just random sequence of bits.
In fact, this is true.
When a particular layer in OSI model.
Hand over its data to a layer below in the OSI model.
So the takeaway from this discussion is that that the sending TCP generates segments and packages,
application data in these segments and assign sequence number to each byte which belong to the application
data in incremental manner.
You.