This tutorial explains in detail TCP features and functions such as the three-way handshaking process, connection, sequencing, acknowledgment, error recovery, flow control, and windowing with examples.

TCP is a feature-rich protocol. It offers guaranteed data delivery. It guarantees that every bit, sent from the source host, reaches the destination host. To provide such a reliable service, TCP deploys five functions; Segmentation, connection multiplexing, three-way contact, sequencing and acknowledgment and flow control by windowing.

From these functions, I have already explained the first two functions in the previous parts of this article. In this part, I will explain the bore of three functions.

This tutorial is the last part of the article “Similarities and differences between TCP and UDP explained with functions” This tutorial explains the following CCNA topic.

Compare and contrast TCP and UDP protocols

Other parts of this article follow.

Explained segmentation with TCP and UDP Header

This tutorial is the first part of the article. It explains in detail the segmentation process as well as the TCP / UDP header.

Connection multiplexing explained with examples

This tutorial is the second part of the article. It explains what connection multiplexing is and how the TCP and UDP protocols use it to connect to multiple applications simultaneously.

Connection oriented protocol or connectionless protocol

TCP is a connection oriented protocol. The difference between a connection oriented protocol and a connectionless protocol is that a connection oriented protocol does not send any data until a correct connection is established. Establishing the connection refers to the process of initializing protocol-specific functionality.

TCP, in the connection establishment process, initializes the sequence and acknowledgment numbers. TCP refers to this process as the three-way handshake process.

TCP three-way handshake process

The source sends a SYN (synchronization) segment to the destination. This segment indicates that the source wishes to establish a reliable session with the destination.

The destination responds back with a SYN / ACK segment (synchronization / acknowledgment). This segment indicates that the destination has received the connection request from the source and is ready to configure a reliable session with the source.

When receiving a SYN / ACK segment from the destination, the source sends an ACK (acknowledgment) segment to the destination. This segment indicates that the source has received confirmation from the destination and that the session is now fully reliable.

The following figure shows an example of a three-way handshake process.

Once the three-way handshake process is complete, the source and destination can transfer the data.

TCP does not send any data without establishing an appropriate connection. The segments that are used in connection establishment or the three-way negotiation process contain only the header information used to initialize specific TCP functionality. These features are explained below.

Reliability through recognition and sequencing

The term TCP reliability mainly covers the following elements;

  • Recognize and return lost packages
  • Detection and deletion of duplicate packets
  • Recognize and rearrange packets that arrive broken
  • Segment overflow control

To ensure reliability, TCP assigns a sequence number to each segment sent. This number not only allows the destination host to reorder all incoming segments that have arrived outside of control, but also to verify that all sent segments have been received.

Acknowledgment numbers are used in the opposite direction. These numbers are used to send verification of received segments, notification of lost segments and acknowledgment of receipt for subsequent segments.

When receiving all sent segments, to obtain the next segments, the destination sends a segment with a number in the acknowledgment field that is more than the sequence number received.

If a segment is lost during transmission, its sequence number is used in the acknowledgment field to notify the sender.

Both the sequence number and the acknowledgment number are initialized in the three-way contacting process. The source and destination hosts update each other’s sequence numbers in this process.

Once the source and the host know their respective sequence numbers, they use them in the data exchange process. Before taking an example of this process, let’s understand another number which is also initialized in the three-way contact process and which is used with these numbers.

Flow control by windowing

Windowing is the process of controlling the flow of segments. It guarantees that a host does not flood another host with too many segments, overflowing its reception buffer.

In the three-way handshake process, the receiving computer, while responding to the initial segment, updates the sending computer to its window size. The window size is the number of segments it can store in its buffer. Once the sending computer knows the size of the receiving computer window, it can control the flow of the segments.

TCP sequence number and acknowledgment

For example, if the window size of the receiving computer is 4, the sending computer only sends the 4 segments. Once 4 segments are sent, it waits for confirmation from the receiving computer before sending the next 4 segments.

When sending the confirmation, the receiving computer can change the size of the window. For example, it can ask the sending computer to send more or less segments in the next section. This function is called sliding windowing or dynamic windowing. It allows the receiver to control the flow of segments that the sending computer can send.

tcp windowing

Rearrange the segments and in the correct order and delete additional segments

To organize the arriving segments in the correct order, the receiving computer uses the segment sequence numbers. To detect and remove duplicate or additional segments, it compares the received segments with the requested segments. For example, if the receiving computer requested 3 segments by specifying window size 3 in the acknowledgment and received 4 segments, it assumes that one more segment has arrived.

Sequence numbers also help detect duplicate segments. If two or more segments have the same sequence numbers, they are duplicates. Duplicate segments are deleted.

reorganization of TCP

Recovery of lost segments

As mentioned above, the receiving computer compares the arriving segments with the expected segments. If it finds a missing segment, it uses the sequence number for that segment to acknowledge receipt by the receiving computer. When the sending computer receives an acknowledgment of a segment it has already sent, it assumes that the acknowledged segment has lost. When the next set of segments is transmitted (segments equal to the window size), it retransmits the lost segments first and the new segments later. For example, if the window size is 3 and the lost segment is 1, then the transmitted segments will be; lost segment, new segment and new segment.

TCP error recovery

Comparison with UDP

UDP is a connectionless protocol. It does not establish any connection and does not exchange any messages before sending the data.

TCP always starts a session with the three-way handshake process. This means that if an application wants to send its data over TCP, it has to wait until the proper connection is established through the hand shake process.

UDP does not use any mechanism or process before starting the session. This means that if an application wishes to send its data via UDP, it can send its data immediately and without delay.

UDP does not sequence the segments and does not care about the order in which they are sent to the destination. Nor does it take acknowledgment of receipt of the segments sent to verify that they have arrived at their destination. He sends them and forgets them. For this reason, it is also called unreliable protocol.

UDP takes less bandwidth and uses fewer processing cycles compared to TCP.

That’s it for this tutorial. If you like this tutorial, don’t forget to share it with your friends via your favorite social platform.

Author

Write A Comment