Explain the TCP Services in the Computer Network.

Following are some of the services offered by the Transmission Control Protocol (TCP) to the processes at the application layer:

  • Stream Delivery Service.
  • Sending and Receiving Buffers.
  • Bytes and Segments.
  • Full Duplex Service
  • Connection Oriented Service.
  • Reliable Service.

All the above mentioned TCP services are explained below in detail.

Stream Delivery Service

TCP is a stream-oriented protocol. It enables the sending process to deliver data as a stream of bytes and the receiving process to acquire data as a stream of bytes.

TCP creates a working environment so that the sending and receiving procedures are connected by an imaginary "tube", as shown in the figure below:

Sending and Receiving Buffers

The sending and receiving processes cannot produce and receive data at the same speed. Hence, TCP needs a buffer for storage.

There are two methods of buffers used in each dissection, which are as follows:

  • Sending Buffer
  • Receiving Buffer

A buffer can be implemented by using a circular array of 1-byte location, as shown in the figure below. The figure shows the movement of data in one direction on the sending side.

The buffer has three types of locations, which are as follows:

  • Empty Locations.
  • Locations that contain the bytes which have been sent, but not acknowledged. These bytes are kept in the buffer till an acknowledgment is received.
  • The location that contains the bytes which are to be sent by the sending TCP

In practice, the TCP may send only a port of data due to the slowness of the receiving process or congestion in the network.

The buffer at the receiver is divided into two parts as mentioned below:

  • The part was containing empty locations.
  • The part was containing the received bytes, which the sending process can consume.

Bytes and Segments

Buffering is used to handle the difference between the speed of data transmission and data consumption. But only buffering is not enough.

We need one more step before sending the data on the Internet Protocol (IP) layer as a TCP service provider. It needs to send data in the form of packets and not as a stream of bytes.

At the transport layer, TCP groups several bytes into a packet and this is called a segment. A header is added to each segment to exercise control.

The segment is encapsulated in an IP diagram and then transmitted. The entire operation is transparent to the receiving process. The segment may be deceived out of order, lost or corrupted when it receives the receiving end.

The figure given below shows how the segments are created from the bytes in the buffers:

The segments are not of the same size. Each segment can carry hundreds of bytes.

Full-Duplex Service

TCP offers a 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 are sent in both directions.

Connection-Oriented Service

We are already aware that the TCP is a connection-oriented protocol. When a process 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 gets its approval.
  • TCP of process-1 tells TCP of process-2 exchange data in both directions.
  • After completing the data exchange, when buffers on both sides are empty, the two TCPs destroy their buffers

The type of connection in TCP is not physical, but it is virtual. The TCP segment encapsulated in an IP datagram can be sent out of order. These segments can get lost or corrupted and may have to be resend. Each segment may take a different path to reach the destination.

Reliable Service

TCP is a reliable transport protocol. It uses an acknowledgment mechanism for checking the safe and sound arrival of data.