So, guys, going forward now, let us try to understand that why TCP is called a byte oriented protocol.
TCP is called a byte oriented protocol because it keeps track of application data that it has sent to
the receiver or received from the receiver at the byte level.
Right.
So any protocol which keeps track of the data it is sending or receiving at the byte level, then that
particular protocol is categorized as byte oriented protocol.
So let us compare this feature of TCP protocol with the analogy.
TCP sender is sending water flow towards receiver in a pipe.
Right?
So it is as good as like somebody is sending a water flow towards the other end in a pipe where each
drop of water is equivalent to a byte of data.
TCP sender and receiver keeps track of how much water is sent and received by keeping explicit track
of each drop of water separately.
So remember, each drop of water here denotes the byte of a data and also note the word explicit track
of each drop of water.
Explicit track means that the TCP protocol on the sending side and the receiving side keep track of
each byte of data which is being sent or received.
Now, in order to keep a track of each byte of data, we need to identify each byte of data uniquely
for this purpose.
Each byte of data is tracked by a unique ID, and that unique ID is called sequence number.
Right?
So each byte is assigned a unique ID, and that unique ID is called a sequence number.
So look at this diagram.
This diagram simply captures the byte oriented ness of TCP protocol.
However, the sending and the receiving side of a TCP may have different speed, right?
For example, the sending process is sending at the rate of ten megabytes per second, whereas receiving
process is able to process the data at maximum of ten megabytes per second.
Right?
So because of the difference in the speed of the capabilities of the sending TCP and the receiving TCP,
both TCP on the sending and the receiving side need buffers to accumulate the data temporarily.
So on each side of a TCP protocol that is on the sending side and receiving side, we have sending and
receiving buffers.
Remember, TCP protocol is a duplex protocol.
That is, the flow of data is bidirectional in TCP.
Therefore, each side will have standing buffer as well as receiving buffer.
And note that each of these buffers are implemented as circular queues.
In this diagram.
For simplicity, I have shown only the sending buffer on this side as well as the receiving buffer on
the other side.
But remember, since sending process also receive the data from the receiving process.
Therefore sending processes also have another similar buffer called receiving buffer.
But here I am showing you only sending buffer, whereas on the other side I am showing you only receiving
buffer, but sending side will have one more circular buffer called receiving buffer and the receiving
side will have one more circular buffer called sending buffer, which I have not drawn in this diagram
for simplicity.
Now let us try to understand what is going on in this diagram so you can see we have a process which
is running at the application layer and it is a process and we have a TCP protocol which is running
in the transport layer on the sending side.
Similarly, we have a receiving process which is running in the application layer and we have a TCP
protocol which is running in the transport layer on the receiving machine.
Note that the two processes may be running on different machines in the network.
Now when the sanding process needs to send any data to the receiving process, the sending process will
generate bytes of data.
Right?
These bytes of data are written by the TCP protocol into its sending buffer.
Now note that this sending buffer is a circular buffer that is on one side.
The TCP protocol will write the data which is coming from the sending process in this circular buffer.
And from the other side, the TCP protocol will dequeue the bytes which are written in this circular
buffer and package those bytes into small packets called segments and ship those segments to the underlying
layer, which in turn takes the responsibility to ship these segments as packets onto the network.
So if you look carefully at this circular buffer, you can see that the white slots in this circular
buffer are empty slots in which more bytes coming from the sending process can be written, right?
The blue slots of this circular buffers represents the bytes which the sending TCP has already sent
to the receiving TCP.
Whereas pink slots of the circular buffer represents those bytes of data which TCP has received from
sending process but has not yet sent to the receiving process.
So you can see that at any given point of time, the TCP protocol on the sending side can categorize
the data as sent to the recipient process, not send to the recipient process and the data which is
yet to be received from the sending process.
Similarly, if you notice what is going on on the receiving side, you can see that in the circular
buffer on the receiving side, which is actually a receiving buffer.
The pink slot represents the bytes which have been received from the sending TCP, but the TCP protocol
has not yet delivered these bytes to the receiving process which is running in the application layer.
Whereas white slots in this circular buffer represents empty slots which are receiving TCP will use
to store fresh bytes of data coming from sending TCP as soon as receiving TCP pushes.
These bytes of data which are stored in the pink slots of receiving buffer to the application, then
these slots becomes available to store more fresh bytes of data coming from the sending TCP.
So you can see on either ends the Senate TCP uses sending buffer and the receiving TCP uses receive
buffer.
But since the communication is duplex, therefore sending process is also a receiving process and therefore
it will have one more circular buffer called receive buffer.
Right.
And the receiving process is also a sending process.
Therefore it will have one more circular buffer called sending buffer.
So this is one area where you will see that TCP protocol uses circular queues in order to implement
its circular sending and receive buffers.
Also note that that the TCP on the sending side and receiving side is actually managing the data at
the byte level using circular buffers.
Therefore, TCP is called byte oriented protocol.