TCP or Transmission Control Protocol is a transport layer protocol
residing at layer 4 in OSI model and is connection orientated
it once again allows high layer protocols access to the network layer or IP layer
but in this case providing reliability.
It is connection orientated before transmission
a session is establish between 2 devices.
TCP generally implements a full duplex mode of operation.
There are some exceptions but we won’t go into them here
In other words a TCP connection is a pair of virtual circuits
one in each direction which operate in full duplex mode.
The transmitter can receive data at the same time its transmitting.
Both host in a conversation can transmit and receive at the same time.
there is error checking in TCP
because there is a checksum in the datagram to verify that there’s no corruption.
TCP segments are also numbered in sequence
so that the destination can re-order segments and determine if data is missing.
There is also acknowledgement of receipt of data, so all data is acknowledge by the receiver.
the transmitter or sender can re-transmit the segment or terminate the connection
if it determines that the receiver is no longer involve in the conversation.
TCP implements data recovery features
in other words there can be re-transmission of lost data.
So if there’s no acknowledgement of a segment, the segment will be re-transmitted.
TCP segment are sent using IP packets.
The TCP header will follow the IP header supplying information specific to the TCP protocol.
As you can see here the TCP header has many more options than the UDP header.
So firstly you have a 16 bit source port number which identifies the sending port.
We have a 16 bit destination port, which identifies the receiving port.
There’s a 32 bit sequence number, if the SYN bit is set
then this is the initial sequence number.
The sequence number of the actual first data byte are then this sequence number plus 1.
If the SYN bit is not set then the sequence number, is the accumulated sequence number
of the first data byte of this packet for the current session.
It then has a 32 bit acknowledgement number.
If the ACK flag is set or bit is set
then the value of the acknowledgement number
is the next sequence number that the receiver is expecting to receive.
This field acknowledges receipt of all prior bytes.
The fist ACK or acknowledgement sent by each end
acknowledges the other ends initial sequence number but no data.
The header length or data offset specifies the size of the TCP header in 32 bit words.
The minimum size of the header is 5 words and the maximum is 15 words.
The minimum size of the header is 20 bytes
and the maximum size of the header is 60 bytes in IPv4
which allows for up to 40 bytes of options in the header.
The reserve fill the set to 0 and is reserve for future use.
Now there are lot of flags or control bits available in the TCP header
and we won’t go through all of them.
The Congestion Window Reduced Flag is part of a congestion notification mechanism
used in conjunction with the ECE bit or flag
or echo congestion notification echo field or flag.
Once again used in congestion notification.
This can be used in quality of service where the network
and the host communicate to indicate congestion
therefore letting the transmitter know that it needs to slowdown.
The URG flag can indicate that this segment is urgent
and should be process as soon as possible.
The ACK flag as mentioned is used for acknowledgement of data.
PSH is the flag set by TCP sender
to cause the TCP receiver to immediately pass
that segment's data to the receivers application socket
along with all other in order data that the receiver is yet to give to that application.
Reset; resets the connection in other words, the connection is turned down.
SYN is used to synchronize sequence numbers.
Only the first packet sent from each end will have this flag set.
FIN means that there is no more data from the sender.
The window size which is 16 bits in length
specifies the size of the received window
which is the number of bytes that the receiver is currently willing to receive
we'll be talking more about flow control and window sizes in a moment.
TCP also includes a 16 bits TCP checksum
which is used for error checking of the header and the data.
The 16 bit urgent pointer is used with the URG flag
which when set on means that the 16 bit urgent pointer is used.
This indicates an offset from the sequence number indicating the last urgent data byte.
There are also various options available in the TCP
but this are out of the scope of this course.
And lastly we have the data, which is the data from higher layer protocols
encapsulated within the TCP header.
There are some examples of applications that rely on either TCP or UDP.
Examples are file transfer protocols include; FTP or File Transfer Protocol
TFTP or Trivial File Transfer Protocol, NFS or Network File System.
In email we tend to use POP3 or Post Office Protocol to receive mail
Simple Mail Transfer Protocol or SMTP to send mail
or IMAP or Internet Message Access Protocol
which is another protocol used for email retrieval
For remote log in to devices, we could use telnet
which sends traffic in clear text
and is therefore in secure or secure SHELL or SSH
which allows for a secure connection to remote devices.
For network management we can use Simple Network Management Protocol or SNMP
and for name management we can use Domain Name System
which allows for the use of names rather than IP addresses
and translates those meaningful domain names, into IP addresses
so for instance cisco.com will be converted to an IP address
when a user browses the internet.
Before continuing I wanna mention again how the mappings work
between the different layers of the OSI model.
At layer 2 in an Ethernet 2 frame, there’s a field called the type number
which allows a host to differentiate between multiple layer 3 protocols
at layer 3, remember you could be using a protocol like IPv4 or IPv6
or in the old days IPX or apple talk.
So at layer 2 the NEC needs to know which layer 3 protocol to send this traffic to
and the type number is used to differentiate the different layer 3 protocols.
At layer 3 a protocol number is used to differentiate
the different protocols running at layer 4, so in an IP header
the protocol field will denote where the TCP or UDP is being used at layer 4
At layer 4 a port number is used to differentiate multiple applications being use at layer 7.
So it’s important to note that at layer 4 the way TCP or UDP
know which application this traffic is destined to is by the port number.