So guys, continuing with the discussion of TCP protocol, the second property of TCP protocol that
we were going to discuss is that that TCP protocol is a stateful protocol.
Now, stateful means that TCP sender, as well as TCP receiver, keeps track of the data that is being
sent and received.
Right.
So you can see in this diagram the TCP sender and the receiver have already established the connection
successfully.
Right?
Now, after establishing the connection, the TCP sender and receiver will now start exchanging the
data with each other.
Now, since TCP is a stateful protocol, it means that TCP on either ends that is on the sender end
as well as on the receiver end will keep a track of a data that is being exchanged with the other side.
For example, the TCP on the sending side will keep the information about data such as how many bytes
of data has already been sent.
In this case, for example, let us say that 100 bytes of the data is already sent and 500 bytes of
data is yet to be sent.
Right.
The TCP on the sending side is also keeping a track that 200 bytes of data has already been received
from the receiver.
So remember, the TCP connection is a duplex connection.
The flow of data happens in both directions.
The TCP also keeps a track that which byte needs to be resend.
The byte needs to be sent if in case it did not reach its intended recipient.
So you can see that TCP keeps a track of the data that it is interested in exchanging with the peer.
Similarly, TCP on the other side keeps a similar track of the data it is interested in exchanging with
the peer.
So because TCP does the housekeeping of the data, therefore TCP is called stateful protocol.
So takeaway is that the TCP is a stateful protocol because the TCP protocol keeps a track of all the
bytes of the data which it is interested in exchanging with the peer.