So, guys, going forward now, let us try to understand what our segments and what our sequence number.
So first of all, TCP is a transport layer protocol and therefore it is sandwiched between application
layer and network layer or IP layer of TCP IP stack.
So you can see in this diagram I have captured the application layer, the transport layer and the network
layer of a TCP IP stack.
TCP is one protocol of transport layer protocol.
We already know.
The other protocols which belongs to the transport layer is UDP protocol.
So transport layer is a home to TCP protocol and therefore TCP is sandwiched between application layer
and network layer.
Now in this diagram, you can see that the application is sending its own application data to the TCP
protocol, which is running in the transport layer, right?
So when the TCP protocol receives the data from the application, the TCP protocol backs the application
data into discrete messages or packages called segments.
So you can see that here.
TCP protocol has taken the application data as it is.
It has received from the application and before that application data, the TCP protocol has attached
its own TCP header.
So the chunk of data in which the application data is preceded by TCP header is called segments.
Segments are those chunk of data which has TCP header followed by application data.
Now when the TCP protocol has prepared the segment.
The TCP protocol, of course, on the sending side will hand over the segments to the network layer.
Of the TCP IP stack.
Now we are assuming that the network layer of the TCP IP stack is running.
IP protocol.
The other equivalent protocol is IPv6 protocol.
So when the network layer receives the segment from the transport layer, the network layer will then
attach its own header called IP header to the segment.
So to the segment, when the IP header gets attached, then the segment is called IP datagrams, or
simply we call these IP datagrams as packets.
Once the network layer prepares these IP datagrams, then these packets are handed over to the underlying
Ethernet layer or data link layer.
The data link layer attaches its own header called Ethernet header to these IP datagrams.
Now that level of detail I have not shown in this diagram.
In this diagram, I have only captured the journey of application data from application layer to network
layer and then from network layer back to application layer.
Now coming to the receiving side, when the IP datagram is received by the IP layer on the receiving
machine, of course the IP layer will remove its own header that is IP header and deliver the resulting
segment to the TCP IP protocol which is running in the transport layer.
So you can see that after removing the IP header, the packet has now converted into segment.
TCP protocol, then process its own TCP header and identify that which process is actually interested
in this application data.
Now the detail of the application which is interested in this application data is present in this TCP
header in the form of port number.
Now if you are not aware of the port numbers, then probably you need to do some socket programming
here.
But anyways, the TCP protocol identifies the application which is interested in this application data
and TCP protocol then delivers the same application data to the application which is running in the
application layer.
So this diagram actually captures the journey of an application data starting from the sending side
or sending process until the point when the application data is delivered to the receiving process.
Of course, in between the sending side and in between the receiving side, we have an internet.
And on this internet, these IP datagram covers its own journey using layer three network routing.
Now, going forward, size of the segment is decided dynamically and keeps on changing depending on
network and recipient state.
Right.
So suppose if the application is sending TCP, suppose 1000 bytes of application data, then it's not
necessary.
That TCP protocol will take the entire 1000 bytes of application data to create a segment.
Right.
The TCP protocol has to consider whether the network is congested or not and if congested, then how
much it is congested.
Can the sending TCP afford to pump into the network a segment of size 1000 bytes?
So all these dynamics is actually a little complicated.
And on what factors does the TCP protocol decides?
The size of the segment depends on the network as well as recipient state.
We will going to learn this in more detail when we will be diving deep into the TCP protocol in the
subsequent section of this course going forward.
TCP chooses the segment size in order to avoid unnecessary fragmentation at IP layer.
So you must be aware if you have some networking background, that IP layer has its own fragmentation
feature, right?
So one factor for the TCP protocol to choose the segment size is also to avoid unnecessary fragmentation
done by the IP layer.
So, for example, suppose the fragmentation limit of IP layer is 2000 bytes.
It means that the IP layer will perform fragmentation of segments if it receives the segments from the
TCP protocol, whose size exceeds 2000 bytes.
So TCP protocol will take care that it do not manufacture the segments exceeding 2000 bytes.
Segments contain n bytes of data where N is the segment size.
So whenever we will say segment size, it means that segment size represents the size of application
data contained in segments.
So for example, if I say that the segment size is 512 bytes, it means that the application payload
contained in that particular segment is 512 bytes, TCP stamp.
Every byte it is sending or receiving in segments with a unique number called sequence number.
The sequence number of first byte in a segment is also treated as segment number.
Right.
So I will going to discuss these two points in little detail in the next lecture video.