The transmission control protocol (TCP) is a connection-oriented and reliable transport layer protocol that provides process-to-process communication. Like in user datagram protocol (UDP), we refer to the data transfer unit as user datagram in TCP we refer it to as a segment.
Content: Transmission Control Protocol
Transmission control protocol i.e. TCP is one of the transport layer protocols that provide process-to-process communication between two communicating hosts on the network. The TCP protocol is connection-oriented so before starting any exchange of data a connection must be established between the sending and receiving host.
The TCP protocol is a reliable protocol as it has a flow and error control mechanism. The flow control mechanism balances the rate at which the sender can produce data and the rate at which the receiver can consume data. The error control mechanism detects the loss of segment, receiving segments out-of-order, or if the segment is corrupted. If the segment is not acknowledged within a time period the error control mechanism performs a retransmission of the unacknowledged segments.
Transmission Control Protocol Working
When two hosts in the network want to communicate using TCP protocol the entire communication can be categorized into three phases as connection establishment, data exchange, and connection termination.
To establish a connection both sender and receiver have to exchange synchronization and acknowledgement data segment before they could start the communication. To establish the connection between sender and receiver three-way handshake protocol is used.
Three-Way Handshaking Protocol
Step 1: Initially the sender process sends an SYN segment to the receiver process. Here, in the header of the SYN segment, the value of the SYN flag is set. The motive of the SYN segment is to initiate a sequence number of the segments from sender to receiver. However, there is no other information or message for the receiver but it initializes a sequence number which we consider as the initial sequence number ISN. Later when the communication between the sender and receiver starts this ISN is incremented by 1 each time a sender sends a segment to the receiver.
Step 2: The receiver now sends an SYN + ACK segment which has a dual purpose. The first is to send an SYN segment in order to establish communication in the other direction i.e. from receiver to sender. This makes the TCP protocol full-duplex.
The other motive is to send an acknowledgement of the first SYN segment that it had received from the sender. To do this the SYN + ACK segment sets the ACK flag and it also reveals the sequence number of the next segment that it expects from the sender.
The SYN + ACK segment initializes the sequence of the segments from receiver to sender.
Step 3: When the sender receives this SYN + ACK segment from the receiver it sends back acknowledgement for this segment from the receiver i.e. ACK segment. To do this the ACK flag of the ACK segment is set. The ACK segment does not contain any other data and it even does not occupy any sequence number.
1. Process-to-process Communication
As we know TCP provides process-to-process communication where the process on the source and the destination host is identified by the port number assigned to them.
There may be several processes running on the source host. When a process at source has to send data to destination process it forwards the data to TCP at source host along with the pair of socket address which includes IP address of source host plus the port number of source process and IP address of destination host plus the port number of destination process.
When the data arrives at its destination the data is delivered to the intended process on the basis of port address.
2. Stream delivery
TCP allows data streaming which means it lets the sender send a continuous stream of bytes to the receiver and it also lets the receiver accept data as a stream of bytes. Now sender and receiver processes may not produce or consume data at the same rate. So to synchronize the data rate both sender and receiver must implement a storage buffer.
3. Full Duplex Communication
TCP provides full-duplex communication between sender and receiver. That means both the sender process and the receiver process are able to send and receive data at the same time. To implement this both sender and receiver have two buffers i.e. sending buffer and receiving buffer and the TCP segment can be sent in both the direction.
4. Multiplexing and Demultiplexing
Like UDP, TCP protocol is also able to perform multiplexing at the sender side and demultiplexing at the receiving side. At the sender, there may be multiple processes running and each may be sending data so it is the responsibility of TCP to multiplex the data from different processes on the source and pass it on the network.
A receiver may receive data for different processes running on it. At the receiver, TCP demultiplexes the received data and passes it to the corresponding processes.
5. Flow and Error Control
Unlike UDP, TCP has a flow and error control mechanism. TCP at the sender side controls the amount of data that can be accepted by receiver TCP. The receiver side TCP controls the amount of data that can be sent by the sending TCP.
6. Congestion Control
The receiver TCP controls how much data must be sent by the sender. The amount of data sent by the sender also depends on the congestion in the network. Thus TCP also conducts a congestion control mechanism.
7. Connection-oriented Service
If two TCPs in a network want to communicate with each other, first they have to establish a virtual connection between them. Once the connection is established both the TCPs can exchange data and when the communication is over the connection is terminated. To set up a connection between two TCPs three-way handshaking protocol is used.
Advantages and Disadvantages
- TCP provides reliable communication between the communicating hosts in the network.
- TCP protocol controls the flow of segments.
- TCP protocol controls the error in transmitted segments.
- TCP includes a congestion control mechanism.
- All the advantages of TCP produce a large amount of overhead causing the communication quite slow.
So this is all about the transmission control protocol. We have learned about its services, working, advantages and disadvantages.