Transport Layer – Transmission Control Protocol (TCP protocol in internet)

In this post, we will understand the next most important protocol of the transport layer i.e. Transmission Control Protocol (TCP) in detail (other protocol i.e. UDP already covered in the previous post). 

TCP (Transmission control protocol) is a connection-oriented(virtual connections are used) protocol and UDP (User Datagram Protocol) is the connectionless protocol. TCP mainly uses flow and error control mechanisms at the transport level.

TCP, unlike UDP, is a stream-oriented protocol. TCP provides services such as data transfer, reliability, efficient flow control, full-duplex operation, and multiplexing. 

This service benefits applications because they do not have to chop data into blocks (as they are done in UDP) before handing it off to TCP. Instead, the TCP groups bytes into segments and pass them to IP for delivery.  

It allows the sending process to deliver data as a stream of bytes and allows the receiving process to obtain data as a stream of bytes(Please refer to the imaginary “tube” concept explained later in the post).

TCP offers reliability by providing connection-oriented and end-to-end reliable packet delivery through an internetwork (which takes into account both flow and error control).

The sending process first produces (writes to) the stream of bytes, and the receiving process then consumes (reads from) them.
The reliability mechanism of TCP allows devices to deal with lost, duplicate, or delayed packets. A time-out mechanism mainly allows devices to detect lost packets and request retransmission. 

TCP supports a full-duplex operation means that TCP processes can both send as well as receive at the same time.

Relationship between TCP and IP

TCP groups the bytes together into a packet called a segment. TCP will add a header to each segment (for control purposes) and delivers the segment to the IP layer for transmission. Let us understand this in detailed steps:

Each TCP message gets encapsulated or inserted in an IP datagram and then this datagram is sent over the Internet to the destination.

IP transports this datagram from sender to destination, without bothering about the contents of the TCP message.

At the final destination, the IP hands over the message to the TCP software running on the destination computer.

IP acts like postal service and transfers the datagrams from one computer to the other.

Thus TCP mainly deals with the actual data to be transferred and IP takes care of the transfer of that data.

Many applications such as FTP, Remote login TELNET etc. keep sending data to TCP software on the sending computer.

The TCP software acts as a multiplexer at the sending computer. It receives data from various applications, multiplexes the data and hands it over to the IP software at the sending end.

IP adds its own header to this TCP packet and creates an IP packet out of it. Then this packet is sent to its destination.

At the destination, exactly the opposite process will take place. The IP software hands over the multiplexed data to the TCP software

The TCP software at the destination computer then demultiplexes the multiplexed data and gives it to the corresponding applications.

Concept of Port in TCP connection

Applications running on different hosts communicate with TCP with the help of ports. Every application has been allotted a unique 16 bit number which is known as a port.

When an application on one computer wants to communicate using a TCP connection to another application on some other computers these ports prove to be very helpful.

TCP Services At a Glance

Now let’s see some of the important functions provided by this protocol in the transport layer:

  • Stream delivery service
  • Sending and receiving buffers
  • Bytes and segments
  • Connection oriented service
  • Reliable service
  • Process to process communication

We will now briefly look into each of these one by one.

1. Stream delivery service

TCP is a stream-oriented protocol. The sending process delivers data in the form of a stream of bytes and the receiving process receives it in the same manner.

TCP creates a working environment in such a way that the sending and receiving processes seem to be connected by an imaginary “tube”.



Transport Layer - Transmission Control Protocol (TCP protocol in internet)

2. Sending and receiving buffers

The sending and receiving processes may not produce and at the same speed. Hence TCP needs buffers for storage of data at both the ends. There are two types of buffers used in each direction:

  • Sending Buffer and ,
  • Receiving Buffer

In practice. the TCP may be able to send only a part of data which is to be sent, due to slowness of the receiving process or congestion in the network.The buffer at the receiver is divided into two parts :

The part containing empty locations and the part containing the received bytes which can be consumed by the sending process.

TCP keeps these bytes in the buffer until it receives an acknowledgment.The operation of the buffer at the receiver site is simpler. The circular buffer is divided into two areas (white and colored).


3. Bytes and Segments

Buffering is used to handle the difference between the speed of data transmission and data consumption. The IP layer, as a service provider for TCP normally needs to send data in packets, not as a stream of bytes.

At the transport layer. TCP groups a number of bytes to form a packet called a segment.

Note :  The bytes of data being transferred in each connection are numbered by TCP. The numbering starts with a randomly generated number.


Transport Layer - Transmission Control Protocol (TCP protocol in internet)

4. Full Duplex Services

TCP offers full-duplex service where the data can flow in both directions simultaneously. Each TCP will then have a sending buffer and receiving buffer. The TCP segments can travel in both the directions, therefore TCP provides a full duplex service.

5. Connection-Oriented Service

TCP is a connection-oriented protocol. When process – 1 wants to communicate (send and receive) with another process (process – 2), the sequence of operations is as follows:

  • TCP of process – 1 informs TCP of process – 2 and create a connection between them(The two TCPs establish a connection between them).
  • TCP of process – 1 and TCP of process – 2 exchange data in both the directions(Data are exchanged in both directions).
  • After completing the data exchange, when buffers on both sides are empty, the two TCPs destroy their buffers to terminate the connection(The connection is terminated).

6. Reliable Service

TCP is a reliable transport protocol and not unreliable like UDP. Different acknowledgments are used by the receiver to convey the sender the status of data. It uses an acknowledgment mechanism in order to check the safe and sound arrival of data.

Flow, Error and Congestion Control in TCP protocol

TCP provides flow control (UDP does not). The receiver will control the amount of data to be sent by the sender. This will avoid data overflow at the receiver. The TCP uses byte-oriented flow control.The receiver of the data controls the amount of data that is to be sent by the sender. 

The error control mechanism is inbuilt for TCP. This allows TCP to provide a reliable service. The error control mechanism considers a segment as the unit of data for error correction however the byte-oriented error control is provided.

TCP takes the congestion in the network into account. UDP does not do this. If an extremely large number of packets are present in a part of a subnet, the performance degrades.

This situation is called congestion. The solutions to the congestion problems can be divided into two categories or groups as open-loop solutions and closed-loop solutions.

Last but not the least, you may check the next post for more additional details associated with the transport layer . So stay tuned.

Spread the Wisdom !!

Techie Aric

Aric is a tech enthusiast , who love to write about the tech related products and 'How To' blogs . IT Engineer by profession , right now working in the Automation field in a Software product company . The other hobbies includes singing , trekking and writing blogs .

Leave a Reply

Your email address will not be published. Required fields are marked *